summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-01-12 02:27:43 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-01-12 02:27:43 +0000
commit81246910f22e42a1dbe7ae82c893e52b39c86b92 (patch)
tree20d4812bb98ba1e847df39d88a074764bc8753e2 /ext
parent4651a1b94cd8d84a0bbc45729ddf0432adcf4fcd (diff)
* ext/etc/etc.c (etc_getpwuid, etc_getgrgid): fix to correctly
convert uid/gid from VALUE. (backport of r11521) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/etc/etc.c15
-rw-r--r--ext/etc/extconf.rb4
2 files changed, 6 insertions, 13 deletions
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index c9ed3d5..447d833 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -131,16 +131,7 @@ etc_getpwuid(argc, argv, obj)
rb_secure(4);
if (rb_scan_args(argc, argv, "01", &id) == 1) {
-#if HAVE_LONG_LONG && HAVE_TYPE_UID_T
- if (sizeof(uid_t) > sizeof(int)) {
- uid = NUM2ULL(id);
- }
- else {
- uid = NUM2UINT(id);
- }
-#else
- uid = NUM2UINT(id);
-#endif
+ uid = PW_VAL2UID(id);
}
else {
uid = getuid();
@@ -342,11 +333,11 @@ etc_getgrgid(obj, id)
VALUE obj, id;
{
#ifdef HAVE_GETGRENT
- int gid;
+ gid_t gid;
struct group *grp;
rb_secure(4);
- gid = NUM2INT(id);
+ gid = getgid();
grp = getgrgid(gid);
if (grp == 0) rb_raise(rb_eArgError, "can't find group for %d", gid);
return setup_group(grp);
diff --git a/ext/etc/extconf.rb b/ext/etc/extconf.rb
index 2496d36..dbd0672 100644
--- a/ext/etc/extconf.rb
+++ b/ext/etc/extconf.rb
@@ -35,7 +35,9 @@ if a or b or c
f = "U#{f}"
end
end
- $defs.push("-DPW_#{t.chomp('_t').upcase}2VAL=#{f}")
+ t = t.chomp('_t').upcase
+ $defs.push("-DPW_#{t}2VAL=#{f}")
+ $defs.push("-DPW_VAL2#{t}=#{f.sub(/([A-Z]+)2(NUM)/, '\22\1')}")
end
create_makefile("etc")
end