Commit 3d8b46a4 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

Add HAVE_PW_GECOS_IN_PASSWD configuration flag


Change-Id: I2571f00b4b6ba41b7795c8c78c58253e5d0205dd
Signed-off-by: default avatarMike Lockwood <lockwood@google.com>
parent 46aaaa6f
......@@ -682,7 +682,9 @@ fakepw(void)
fake.pw_name = "NOUSER";
fake.pw_passwd =
"$2a$06$r3.juUaHZDlIbQaO2dS9FuYxL1W9M81R1Tc92PoSNmzvpEqLkLGrK";
#ifdef HAVE_PW_GECOS_IN_PASSWD
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
......
......@@ -732,6 +732,9 @@
/* Define if your password has a pw_change field */
#undef HAVE_PW_CHANGE_IN_PASSWD
/* Define if your password has a pw_gecos field */
#undef HAVE_PW_GECOS_IN_PASSWD
/* Define if your password has a pw_class field */
#undef HAVE_PW_CLASS_IN_PASSWD
......
......@@ -13620,6 +13620,40 @@ $as_echo "#define HAVE_PW_CHANGE_IN_PASSWD 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pw_gecos field in struct passwd" >&5
$as_echo_n "checking for pw_gecos field in struct passwd... " >&6; }
if ${ac_cv_have_pw_gecos_in_struct_passwd+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <pwd.h>
int
main ()
{
struct passwd p; p.pw_gecos = 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_have_pw_gecos_in_struct_passwd="yes"
else
ac_cv_have_pw_gecos_in_struct_passwd="no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_pw_gecos_in_struct_passwd" >&5
$as_echo "$ac_cv_have_pw_gecos_in_struct_passwd" >&6; }
if test "x$ac_cv_have_pw_gecos_in_struct_passwd" = "xyes" ; then
$as_echo "#define HAVE_PW_GECOS_IN_PASSWD 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for msg_accrights field in struct msghdr" >&5
$as_echo_n "checking for msg_accrights field in struct msghdr... " >&6; }
if ${ac_cv_have_accrights_in_msghdr+:} false; then :
......
......@@ -3100,6 +3100,19 @@ if test "x$ac_cv_have_pw_change_in_struct_passwd" = "xyes" ; then
[Define if your password has a pw_change field])
fi
AC_CACHE_CHECK([for pw_gecos field in struct passwd],
ac_cv_have_pw_gecos_in_struct_passwd, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <pwd.h> ]],
[[ struct passwd p; p.pw_gecos = 0; ]])],
[ ac_cv_have_pw_gecos_in_struct_passwd="yes" ],
[ ac_cv_have_pw_gecos_in_struct_passwd="no"
])
])
if test "x$ac_cv_have_pw_gecos_in_struct_passwd" = "xyes" ; then
AC_DEFINE([HAVE_PW_GECOS_IN_PASSWD], [1],
[Define if your password has a pw_gecos 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, [
......
......@@ -205,8 +205,10 @@ pwcopy(struct passwd *pw)
struct passwd *copy = xcalloc(1, sizeof(*copy));
copy->pw_name = xstrdup(pw->pw_name);
copy->pw_passwd = xstrdup(pw->pw_passwd);
copy->pw_passwd = pw->pw_passwd ? xstrdup(pw->pw_passwd) : NULL;
#ifdef HAVE_PW_GECOS_IN_PASSWD
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
......
......@@ -761,7 +761,9 @@ 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_PW_GECOS_IN_PASSWD
buffer_put_cstring(m, pwent->pw_gecos);
#endif
#ifdef HAVE_PW_CLASS_IN_PASSWD
buffer_put_cstring(m, pwent->pw_class);
#endif
......
......@@ -259,7 +259,9 @@ 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_PW_GECOS_IN_PASSWD
pw->pw_gecos = buffer_get_string(&m, NULL);
#endif
#ifdef HAVE_PW_CLASS_IN_PASSWD
pw->pw_class = buffer_get_string(&m, NULL);
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment