Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 267b639

Browse files
author
Stefan Krah
committed
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.
1 parent 8e1da58 commit 267b639

4 files changed

Lines changed: 45 additions & 0 deletions

File tree

Modules/pwdmodule.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,18 @@ mkpwent(struct passwd *p)
7575
#define SETS(i,val) sets(v, i, val)
7676

7777
SETS(setIndex++, p->pw_name);
78+
#if defined(HAVE_STRUCT_PASSWD_PW_PASSWD)
7879
SETS(setIndex++, p->pw_passwd);
80+
#else
81+
SETS(setIndex++, "");
82+
#endif
7983
PyStructSequence_SET_ITEM(v, setIndex++, _PyLong_FromUid(p->pw_uid));
8084
PyStructSequence_SET_ITEM(v, setIndex++, _PyLong_FromGid(p->pw_gid));
85+
#if defined(HAVE_STRUCT_PASSWD_PW_GECOS)
8186
SETS(setIndex++, p->pw_gecos);
87+
#else
88+
SETS(setIndex++, "");
89+
#endif
8290
SETS(setIndex++, p->pw_dir);
8391
SETS(setIndex++, p->pw_shell);
8492

configure

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12916,6 +12916,33 @@ cat >>confdefs.h <<_ACEOF
1291612916
_ACEOF
1291712917

1291812918

12919+
fi
12920+
12921+
ac_fn_c_check_member "$LINENO" "struct passwd" "pw_gecos" "ac_cv_member_struct_passwd_pw_gecos" "
12922+
#include <sys/types.h>
12923+
#include <pwd.h>
12924+
12925+
"
12926+
if test "x$ac_cv_member_struct_passwd_pw_gecos" = xyes; then :
12927+
12928+
cat >>confdefs.h <<_ACEOF
12929+
#define HAVE_STRUCT_PASSWD_PW_GECOS 1
12930+
_ACEOF
12931+
12932+
12933+
fi
12934+
ac_fn_c_check_member "$LINENO" "struct passwd" "pw_passwd" "ac_cv_member_struct_passwd_pw_passwd" "
12935+
#include <sys/types.h>
12936+
#include <pwd.h>
12937+
12938+
"
12939+
if test "x$ac_cv_member_struct_passwd_pw_passwd" = xyes; then :
12940+
12941+
cat >>confdefs.h <<_ACEOF
12942+
#define HAVE_STRUCT_PASSWD_PW_PASSWD 1
12943+
_ACEOF
12944+
12945+
1291912946
fi
1292012947

1292112948

configure.ac

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3762,6 +3762,10 @@ AC_CHECK_MEMBERS([struct stat.st_flags])
37623762
AC_CHECK_MEMBERS([struct stat.st_gen])
37633763
AC_CHECK_MEMBERS([struct stat.st_birthtime])
37643764
AC_CHECK_MEMBERS([struct stat.st_blocks])
3765+
AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_passwd], [], [], [[
3766+
#include <sys/types.h>
3767+
#include <pwd.h>
3768+
]])
37653769

37663770
AC_MSG_CHECKING(for time.h that defines altzone)
37673771
AC_CACHE_VAL(ac_cv_header_time_altzone,[

pyconfig.h.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,12 @@
916916
/* Define to 1 if you have the <stropts.h> header file. */
917917
#undef HAVE_STROPTS_H
918918

919+
/* Define to 1 if `pw_gecos' is a member of `struct passwd'. */
920+
#undef HAVE_STRUCT_PASSWD_PW_GECOS
921+
922+
/* Define to 1 if `pw_passwd' is a member of `struct passwd'. */
923+
#undef HAVE_STRUCT_PASSWD_PW_PASSWD
924+
919925
/* Define to 1 if `st_birthtime' is a member of `struct stat'. */
920926
#undef HAVE_STRUCT_STAT_ST_BIRTHTIME
921927

0 commit comments

Comments
 (0)