summaryrefslogtreecommitdiff
path: root/ext/etc
diff options
context:
space:
mode:
Diffstat (limited to 'ext/etc')
-rw-r--r--ext/etc/etc.c28
-rw-r--r--ext/etc/extconf.rb20
2 files changed, 21 insertions, 27 deletions
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 76af10be77..b10943458d 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -58,27 +58,27 @@ setup_passwd(pwd)
rb_tainted_str_new2(pwd->pw_passwd),
INT2FIX(pwd->pw_uid),
INT2FIX(pwd->pw_gid),
-#ifdef PW_GECOS
+#ifdef HAVE_ST_PW_GECOS
rb_tainted_str_new2(pwd->pw_gecos),
#endif
rb_tainted_str_new2(pwd->pw_dir),
rb_tainted_str_new2(pwd->pw_shell),
-#ifdef PW_CHANGE
+#ifdef HAVE_ST_PW_CHANGE
INT2FIX(pwd->pw_change),
#endif
-#ifdef PW_QUOTA
+#ifdef HAVE_ST_PW_QUOTA
INT2FIX(pwd->pw_quota),
#endif
-#ifdef PW_AGE
+#ifdef HAVE_ST_PW_AGE
INT2FIX(pwd->pw_age),
#endif
-#ifdef PW_CLASS
+#ifdef HAVE_ST_PW_CLASS
rb_tainted_str_new2(pwd->pw_class),
#endif
-#ifdef PW_COMMENT
+#ifdef HAVE_ST_PW_COMMENT
rb_tainted_str_new2(pwd->pw_comment),
#endif
-#ifdef PW_EXPIRE
+#ifdef HAVE_ST_PW_EXPIRE
INT2FIX(pwd->pw_expire),
#endif
0 /*dummy*/
@@ -294,26 +294,26 @@ Init_etc()
sPasswd = rb_struct_define("Passwd",
"name", "passwd", "uid", "gid",
-#ifdef PW_GECOS
+#ifdef HAVE_ST_PW_GECOS
"gecos",
#endif
"dir", "shell",
-#ifdef PW_CHANGE
+#ifdef HAVE_ST_PW_CHANGE
"change",
#endif
-#ifdef PW_QUOTA
+#ifdef HAVE_ST_PW_QUOTA
"quota",
#endif
-#ifdef PW_AGE
+#ifdef HAVE_ST_PW_AGE
"age",
#endif
-#ifdef PW_CLASS
+#ifdef HAVE_ST_PW_CLASS
"uclass",
#endif
-#ifdef PW_COMMENT
+#ifdef HAVE_ST_PW_COMMENT
"comment",
#endif
-#ifdef PW_EXPIRE
+#ifdef HAVE_ST_PW_EXPIRE
"expire",
#endif
0);
diff --git a/ext/etc/extconf.rb b/ext/etc/extconf.rb
index b920d91a95..bf6890ca9d 100644
--- a/ext/etc/extconf.rb
+++ b/ext/etc/extconf.rb
@@ -1,22 +1,16 @@
require 'mkmf'
-def etc_grep_header(field)
- if egrep_cpp(field, "#include <pwd.h>\n")
- $defs.push(format("-D%s", field.upcase))
- end
-end
-
have_library("sun", "getpwnam") # NIS (== YP) interface for IRIX 4
a = have_func("getlogin")
b = have_func("getpwent")
c = have_func("getgrent")
if a or b or c
- etc_grep_header("pw_gecos")
- etc_grep_header("pw_change")
- etc_grep_header("pw_quota")
- etc_grep_header("pw_age")
- etc_grep_header("pw_class")
- etc_grep_header("pw_comment") unless /cygwin/ === RUBY_PLATFORM
- etc_grep_header("pw_expire")
+ have_struct_member('struct passwd', 'pw_gecos', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_change', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_quota', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_age', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_class', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_comment', 'pwd.h') unless /cygwin/ === RUBY_PLATFORM
+ have_struct_member('struct passwd', 'pw_expire', 'pwd.h')
create_makefile("etc")
end