diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-04-09 09:24:07 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-04-09 09:44:18 +0900 |
commit | f099bb040c26708ecdb4f5e552843717caaba70b (patch) | |
tree | 48ad85cd41442d9128f2c54c12defb2d01759e90 /ext | |
parent | 9af3469b84d6220ef30ffc2b3709806f90edaf41 (diff) |
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.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/etc/etc.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/etc/etc.c b/ext/etc/etc.c index d57c26555b..5c08ba82ce 100644 --- a/ext/etc/etc.c +++ b/ext/etc/etc.c @@ -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*/ ); |