summaryrefslogtreecommitdiff
path: root/ext/etc
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-06-27 02:37:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-06-27 02:37:01 +0000
commit6de2f53f986465a0d0d86eb8619ebd7cf5bce1e8 (patch)
tree9904eb92fc62a5d4d4843b7569693d3eb2d25fa3 /ext/etc
parent8ae45d642f086128e9f632cb8320d78bf5528735 (diff)
* ext/etc/etc.c (setup_passwd, setup_group): allow bignum uid, gid and
so on. [ruby-talk:199102] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/etc')
-rw-r--r--ext/etc/etc.c12
-rw-r--r--ext/etc/extconf.rb15
2 files changed, 20 insertions, 7 deletions
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 64d46c7..05d40ca 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -76,18 +76,18 @@ setup_passwd(struct passwd *pwd)
#ifdef HAVE_ST_PW_PASSWD
safe_setup_str(pwd->pw_passwd),
#endif
- INT2FIX(pwd->pw_uid),
- INT2FIX(pwd->pw_gid),
+ PW_UID2VAL(pwd->pw_uid),
+ PW_GID2VAL(pwd->pw_gid),
#ifdef HAVE_ST_PW_GECOS
safe_setup_str(pwd->pw_gecos),
#endif
safe_setup_str(pwd->pw_dir),
safe_setup_str(pwd->pw_shell),
#ifdef HAVE_ST_PW_CHANGE
- INT2FIX(pwd->pw_change),
+ INT2NUM(pwd->pw_change),
#endif
#ifdef HAVE_ST_PW_QUOTA
- INT2FIX(pwd->pw_quota),
+ INT2NUM(pwd->pw_quota),
#endif
#ifdef HAVE_ST_PW_AGE
PW_AGE2VAL(pwd->pw_age),
@@ -99,7 +99,7 @@ setup_passwd(struct passwd *pwd)
safe_setup_str(pwd->pw_comment),
#endif
#ifdef HAVE_ST_PW_EXPIRE
- INT2FIX(pwd->pw_expire),
+ INT2NUM(pwd->pw_expire),
#endif
0 /*dummy*/
);
@@ -301,7 +301,7 @@ setup_group(struct group *grp)
#ifdef HAVE_ST_GR_PASSWD
safe_setup_str(grp->gr_passwd),
#endif
- INT2FIX(grp->gr_gid),
+ PW_GID2VAL(grp->gr_gid),
mem);
}
#endif
diff --git a/ext/etc/extconf.rb b/ext/etc/extconf.rb
index 0dc8e7d..5cdb824 100644
--- a/ext/etc/extconf.rb
+++ b/ext/etc/extconf.rb
@@ -24,6 +24,19 @@ if a or b or c
have_struct_member('struct passwd', 'pw_expire', 'pwd.h')
have_struct_member('struct passwd', 'pw_passwd', 'pwd.h')
have_struct_member('struct group', 'gr_passwd', 'grp.h')
- have_type("uid_t");
+ [%w"uid_t pwd.h", %w"gid_t grp.h"].each do |t, *h|
+ h << "sys/types.h"
+ if have_type(t, h)
+ if try_static_assert("sizeof(#{t}) > sizeof(long)", h)
+ f = "LL2NUM"
+ else
+ f = "INT2NUM"
+ end
+ if try_static_assert("(#{t})-1 > 0", h)
+ f = "U#{f}"
+ end
+ $defs.push("-DPW_#{t.chomp('_t').upcase}2VAL=#{f}")
+ end
+ end
create_makefile("etc")
end