[Python-checkins] cpython: Issue #20306: The pw_gecos and pw_passwd fields are not required by POSIX.

stefan.krah python-checkins at python.org
Mon Apr 25 19:10:47 EDT 2016


https://hg.python.org/cpython/rev/0d74d4937ab9
changeset:   101145:0d74d4937ab9
user:        Stefan Krah <skrah at bytereef.org>
date:        Tue Apr 26 01:09:18 2016 +0200
summary:
  Issue #20306: The pw_gecos and pw_passwd fields are not required by POSIX.
If they aren't present, set them to an empty string.

files:
  Modules/pwdmodule.c |   8 ++++++++
  configure           |  27 +++++++++++++++++++++++++++
  configure.ac        |   4 ++++
  pyconfig.h.in       |   6 ++++++
  4 files changed, 45 insertions(+), 0 deletions(-)


diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c
--- a/Modules/pwdmodule.c
+++ b/Modules/pwdmodule.c
@@ -75,10 +75,18 @@
 #define SETS(i,val) sets(v, i, val)
 
     SETS(setIndex++, p->pw_name);
+#if defined(HAVE_STRUCT_PASSWD_PW_PASSWD)
     SETS(setIndex++, p->pw_passwd);
+#else
+    SETS(setIndex++, "");
+#endif
     PyStructSequence_SET_ITEM(v, setIndex++, _PyLong_FromUid(p->pw_uid));
     PyStructSequence_SET_ITEM(v, setIndex++, _PyLong_FromGid(p->pw_gid));
+#if defined(HAVE_STRUCT_PASSWD_PW_GECOS)
     SETS(setIndex++, p->pw_gecos);
+#else
+    SETS(setIndex++, "");
+#endif
     SETS(setIndex++, p->pw_dir);
     SETS(setIndex++, p->pw_shell);
 
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -12918,6 +12918,33 @@
 
 fi
 
+ac_fn_c_check_member "$LINENO" "struct passwd" "pw_gecos" "ac_cv_member_struct_passwd_pw_gecos" "
+  #include <sys/types.h>
+  #include <pwd.h>
+
+"
+if test "x$ac_cv_member_struct_passwd_pw_gecos" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_PASSWD_PW_GECOS 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_member "$LINENO" "struct passwd" "pw_passwd" "ac_cv_member_struct_passwd_pw_passwd" "
+  #include <sys/types.h>
+  #include <pwd.h>
+
+"
+if test "x$ac_cv_member_struct_passwd_pw_passwd" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_PASSWD_PW_PASSWD 1
+_ACEOF
+
+
+fi
+
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for time.h that defines altzone" >&5
 $as_echo_n "checking for time.h that defines altzone... " >&6; }
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -3762,6 +3762,10 @@
 AC_CHECK_MEMBERS([struct stat.st_gen])
 AC_CHECK_MEMBERS([struct stat.st_birthtime])
 AC_CHECK_MEMBERS([struct stat.st_blocks])
+AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_passwd], [], [], [[
+  #include <sys/types.h>
+  #include <pwd.h>
+]])
 
 AC_MSG_CHECKING(for time.h that defines altzone)
 AC_CACHE_VAL(ac_cv_header_time_altzone,[
diff --git a/pyconfig.h.in b/pyconfig.h.in
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -916,6 +916,12 @@
 /* Define to 1 if you have the <stropts.h> header file. */
 #undef HAVE_STROPTS_H
 
+/* Define to 1 if `pw_gecos' is a member of `struct passwd'. */
+#undef HAVE_STRUCT_PASSWD_PW_GECOS
+
+/* Define to 1 if `pw_passwd' is a member of `struct passwd'. */
+#undef HAVE_STRUCT_PASSWD_PW_PASSWD
+
 /* Define to 1 if `st_birthtime' is a member of `struct stat'. */
 #undef HAVE_STRUCT_STAT_ST_BIRTHTIME
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list