Ignore upper bits of pw_expire on macOS

`pw_expire` is declared as `time_t`, but actually not, and
`getpwuid` returns a garbage there.

Also the declaration of `struct passwd` in pwd.h and the manual
page contradict each other, interal `pw_fields` is mentioned only
in the latter.  Maybe there is a confusion.
This commit is contained in:
Nobuyoshi Nakada 2020-04-09 09:24:07 +09:00
parent 9af3469b84
commit f099bb040c
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6

View File

@ -125,6 +125,12 @@ safe_setup_filesystem_str(const char *str)
#endif
#ifdef HAVE_GETPWENT
# ifdef __APPLE__
# define PW_EXPIRE2VAL(t) INT2NUM((int)(t))
# else
# define PW_EXPIRE2VAL(t) TIMET2NUM(t)
# endif
static VALUE
setup_passwd(struct passwd *pwd)
{
@ -157,7 +163,7 @@ setup_passwd(struct passwd *pwd)
safe_setup_locale_str(pwd->pw_comment),
#endif
#ifdef HAVE_STRUCT_PASSWD_PW_EXPIRE
TIMET2NUM(pwd->pw_expire),
PW_EXPIRE2VAL(pwd->pw_expire),
#endif
0 /*dummy*/
);