mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
r11523@ruby: shyouhei | 2007-01-09 15:57:58 +0900
* ext/etc/etc.c (etc_getpwuid, etc_getgrgid): fix to correctly convert uid/gid from VALUE. * ext/etc/etc.c (etc_getpwuid): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
61fbdef349
commit
42b298560b
3 changed files with 19 additions and 18 deletions
|
@ -1,7 +1,9 @@
|
|||
Tue Jan 9 17:48:38 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
Tue Jan 9 12:29:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* file.c (rb_find_file): should not call fpath_check() with NULL.
|
||||
fixed: [ruby-core:09867]
|
||||
* ext/etc/etc.c (etc_getpwuid, etc_getgrgid): fix to correctly
|
||||
convert uid/gid from VALUE.
|
||||
|
||||
* ext/etc/etc.c (etc_getpwuid): ditto.
|
||||
|
||||
Tue Jan 9 03:54:38 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
|
|
|
@ -125,16 +125,7 @@ etc_getpwuid(int argc, VALUE *argv, VALUE 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();
|
||||
|
@ -326,14 +317,20 @@ setup_group(struct group *grp)
|
|||
*
|
||||
*/
|
||||
static VALUE
|
||||
etc_getgrgid(VALUE obj, VALUE id)
|
||||
etc_getgrgid(int argc, VALUE *argv, VALUE obj)
|
||||
{
|
||||
#ifdef HAVE_GETGRENT
|
||||
int gid;
|
||||
VALUE id;
|
||||
gid_t gid;
|
||||
struct group *grp;
|
||||
|
||||
rb_secure(4);
|
||||
gid = NUM2INT(id);
|
||||
if (rb_scan_args(argc, argv, "01", &id) == 1) {
|
||||
gid = PW_VAL2GID(id);
|
||||
}
|
||||
else {
|
||||
gid = getgid();
|
||||
}
|
||||
grp = getgrgid(gid);
|
||||
if (grp == 0) rb_raise(rb_eArgError, "can't find group for %d", gid);
|
||||
return setup_group(grp);
|
||||
|
@ -505,7 +502,7 @@ Init_etc(void)
|
|||
rb_define_module_function(mEtc, "getpwent", etc_getpwent, 0);
|
||||
rb_define_module_function(mEtc, "passwd", etc_passwd, 0);
|
||||
|
||||
rb_define_module_function(mEtc, "getgrgid", etc_getgrgid, 1);
|
||||
rb_define_module_function(mEtc, "getgrgid", etc_getgrgid, -1);
|
||||
rb_define_module_function(mEtc, "getgrnam", etc_getgrnam, 1);
|
||||
rb_define_module_function(mEtc, "group", etc_group, 0);
|
||||
rb_define_module_function(mEtc, "setgrent", etc_setgrent, 0);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue