[前][次][番号順一覧][スレッド一覧]

ruby-changes:60708

From: Nobuyoshi <ko1@a...>
Date: Thu, 9 Apr 2020 09:44:48 +0900 (JST)
Subject: [ruby-changes:60708] f099bb040c (master): Ignore upper bits of pw_expire on macOS

https://git.ruby-lang.org/ruby.git/commit/?id=f099bb040c

From f099bb040c26708ecdb4f5e552843717caaba70b Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 9 Apr 2020 09:24:07 +0900
Subject: 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.

diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index d57c265..5c08ba8 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -125,6 +125,12 @@ safe_setup_filesystem_str(const char *str) https://github.com/ruby/ruby/blob/trunk/ext/etc/etc.c#L125
 #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) https://github.com/ruby/ruby/blob/trunk/ext/etc/etc.c#L163
 			 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*/
 	);
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]