- (djm) [auth.c configure.ac misc.c monitor.c monitor_wrap.c] Support

platforms, such as Android, that lack struct passwd.pw_gecos. Report
   and initial patch from Nathan Osman bz#2086; feedback tim@ ok dtucker@
This commit is contained in:
Damien Miller 2013-04-23 14:25:52 +10:00
parent ce1c9574fc
commit 6332da2ae8
6 changed files with 30 additions and 49 deletions

View File

@ -1,3 +1,8 @@
20130423
- (djm) [auth.c configure.ac misc.c monitor.c monitor_wrap.c] Support
platforms, such as Android, that lack struct passwd.pw_gecos. Report
and initial patch from Nathan Osman bz#2086; feedback tim@ ok dtucker@
20130418
- (djm) [config.guess config.sub] Update to last versions before they switch
to GPL3. ok dtucker@

4
auth.c
View File

@ -721,10 +721,12 @@ fakepw(void)
fake.pw_name = "NOUSER";
fake.pw_passwd =
"$2a$06$r3.juUaHZDlIbQaO2dS9FuYxL1W9M81R1Tc92PoSNmzvpEqLkLGrK";
#ifdef HAVE_STRUCT_PASSWD_PW_GECOS
fake.pw_gecos = "NOUSER";
#endif
fake.pw_uid = privsep_pw == NULL ? (uid_t)-1 : privsep_pw->pw_uid;
fake.pw_gid = privsep_pw == NULL ? (gid_t)-1 : privsep_pw->pw_gid;
#ifdef HAVE_PW_CLASS_IN_PASSWD
#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
fake.pw_class = "";
#endif
fake.pw_dir = "/nonexist";

View File

@ -1,4 +1,4 @@
# $Id: configure.ac,v 1.520 2013/04/18 11:36:20 dtucker Exp $
# $Id: configure.ac,v 1.521 2013/04/23 04:25:53 djm Exp $
#
# Copyright (c) 1999-2004 Damien Miller
#
@ -15,7 +15,7 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
AC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org])
AC_REVISION($Revision: 1.520 $)
AC_REVISION($Revision: 1.521 $)
AC_CONFIG_SRCDIR([ssh.c])
AC_LANG([C])
@ -3303,9 +3303,16 @@ OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmpx.h], [HAVE_TIME_IN_UTMPX])
OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmpx.h], [HAVE_TV_IN_UTMPX])
AC_CHECK_MEMBERS([struct stat.st_blksize])
AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_class,
struct passwd.pw_change, struct passwd.pw_expire],
[], [], [[
#include <sys/types.h>
#include <pwd.h>
]])
AC_CHECK_MEMBER([struct __res_state.retrans], [], [AC_DEFINE([__res_state], [state],
[Define if we don't have struct __res_state in resolv.h])],
[
[[
#include <stdio.h>
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
@ -3313,7 +3320,7 @@ AC_CHECK_MEMBER([struct __res_state.retrans], [], [AC_DEFINE([__res_state], [sta
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
])
]])
AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
ac_cv_have_ss_family_in_struct_ss, [
@ -3343,45 +3350,6 @@ if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
[Fields in struct sockaddr_storage])
fi
AC_CACHE_CHECK([for pw_class field in struct passwd],
ac_cv_have_pw_class_in_struct_passwd, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <pwd.h> ]],
[[ struct passwd p; p.pw_class = 0; ]])],
[ ac_cv_have_pw_class_in_struct_passwd="yes" ],
[ ac_cv_have_pw_class_in_struct_passwd="no"
])
])
if test "x$ac_cv_have_pw_class_in_struct_passwd" = "xyes" ; then
AC_DEFINE([HAVE_PW_CLASS_IN_PASSWD], [1],
[Define if your password has a pw_class field])
fi
AC_CACHE_CHECK([for pw_expire field in struct passwd],
ac_cv_have_pw_expire_in_struct_passwd, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <pwd.h> ]],
[[ struct passwd p; p.pw_expire = 0; ]])],
[ ac_cv_have_pw_expire_in_struct_passwd="yes" ],
[ ac_cv_have_pw_expire_in_struct_passwd="no"
])
])
if test "x$ac_cv_have_pw_expire_in_struct_passwd" = "xyes" ; then
AC_DEFINE([HAVE_PW_EXPIRE_IN_PASSWD], [1],
[Define if your password has a pw_expire field])
fi
AC_CACHE_CHECK([for pw_change field in struct passwd],
ac_cv_have_pw_change_in_struct_passwd, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <pwd.h> ]],
[[ struct passwd p; p.pw_change = 0; ]])],
[ ac_cv_have_pw_change_in_struct_passwd="yes" ],
[ ac_cv_have_pw_change_in_struct_passwd="no"
])
])
if test "x$ac_cv_have_pw_change_in_struct_passwd" = "xyes" ; then
AC_DEFINE([HAVE_PW_CHANGE_IN_PASSWD], [1],
[Define if your password has a pw_change field])
fi
dnl make sure we're using the real structure members and not defines
AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
ac_cv_have_accrights_in_msghdr, [

8
misc.c
View File

@ -206,16 +206,18 @@ pwcopy(struct passwd *pw)
copy->pw_name = xstrdup(pw->pw_name);
copy->pw_passwd = xstrdup(pw->pw_passwd);
#ifdef HAVE_STRUCT_PASSWD_PW_GECOS
copy->pw_gecos = xstrdup(pw->pw_gecos);
#endif
copy->pw_uid = pw->pw_uid;
copy->pw_gid = pw->pw_gid;
#ifdef HAVE_PW_EXPIRE_IN_PASSWD
#ifdef HAVE_STRUCT_PASSWD_PW_EXPIRE
copy->pw_expire = pw->pw_expire;
#endif
#ifdef HAVE_PW_CHANGE_IN_PASSWD
#ifdef HAVE_STRUCT_PASSWD_PW_CHANGE
copy->pw_change = pw->pw_change;
#endif
#ifdef HAVE_PW_CLASS_IN_PASSWD
#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
copy->pw_class = xstrdup(pw->pw_class);
#endif
copy->pw_dir = xstrdup(pw->pw_dir);

View File

@ -778,8 +778,10 @@ mm_answer_pwnamallow(int sock, Buffer *m)
buffer_put_string(m, pwent, sizeof(struct passwd));
buffer_put_cstring(m, pwent->pw_name);
buffer_put_cstring(m, "*");
#ifdef HAVE_STRUCT_PASSWD_PW_GECOS
buffer_put_cstring(m, pwent->pw_gecos);
#ifdef HAVE_PW_CLASS_IN_PASSWD
#endif
#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
buffer_put_cstring(m, pwent->pw_class);
#endif
buffer_put_cstring(m, pwent->pw_dir);

View File

@ -259,8 +259,10 @@ mm_getpwnamallow(const char *username)
fatal("%s: struct passwd size mismatch", __func__);
pw->pw_name = buffer_get_string(&m, NULL);
pw->pw_passwd = buffer_get_string(&m, NULL);
#ifdef HAVE_STRUCT_PASSWD_PW_GECOS
pw->pw_gecos = buffer_get_string(&m, NULL);
#ifdef HAVE_PW_CLASS_IN_PASSWD
#endif
#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
pw->pw_class = buffer_get_string(&m, NULL);
#endif
pw->pw_dir = buffer_get_string(&m, NULL);