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.
This commit is contained in:
Stefan Krah 2016-04-26 01:09:18 +02:00
parent 8e1da5823b
commit 267b639a26
4 changed files with 45 additions and 0 deletions

View file

@ -75,10 +75,18 @@ mkpwent(struct passwd *p)
#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);