Etc.getgrgid が getgid の値に固定されています


#1

e$B?"ED$H?=$7$^$9!#e(B

e$B!!4{=P$+$b$7$l$^$;$s$,!e(Bruby 1.8.6, 1.8.5-p32
e$B6&$K!Ve(Bruby-1.8.5-p12 e$B$^$Ge(B
e$B$OBg>fIW$@$C$?e(B Etc.getgrgid
e$B$,$*$+$7$$!W$H$$$&Js9p$,<RFb$G$$j$^$7$?!#e(B


[root@example ~]# egrep ^root|^users /etc/group
root:x:0:root
users:x:100:foo,bar,hoge,fuga

[root@example ~]$ irb
irb(main):001:0> require etc
=> true
irb(main):002:0> Etc.getgrgid(100)
=> #<struct Struct::Group name=users, passwd=x, gid=100, mem=[foo,
bar, hoge, fuga]>
irb(main):003:0> RUBY_VERSION
=> 1.8.5
irb(main):004:0> RUBY_PLATFORM
=> i686-linux
[root@example ~]$ irb
irb(main):001:0> require etc
=> true
irb(main):002:0> Etc.getgrgid(100)
=> #<struct Struct::Group name=root, passwd=x, gid=0, mem=[root]>
irb(main):003:0> RUBY_VERSION
=> 1.8.6
irb(main):004:0> RUBY_PLATFORM
=> i686-linux

e$B0J2<$NJQ99$K$h$k1F6A$N$h$&$G$9!#e(B

http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v1_8_5_35/ext/etc/etc.c?r1=10775&r2=11521
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v1_8_6/ext/etc/etc.c?r1=10979&r2=11526

getgrgid() e$B$KEO$9CM$re(B getgid()
e$B$G<hF@$7$F$$$k$N$G$9$,!"$3$l$@$He(B etc_getgrgid(obj, id)
e$B$Ne(B id e$B$,A4$/;H$o$l$^$;$s$7e(B

e$B!!@5$7$/$J$$$3$H$O>5CN$G0J2<$N=$@5$r$9$k$H!"$H$j$"$($:e(B i386
e$B$Ne(B CentOS
4.4 e$B>e$G$O@5$7$$7k2L$,F@$i$l$F$$$^$9!#e(B

etc.c.orig 2007-03-15 12:07:33.000000000 +0900
+++ etc.c 2007-03-15 12:15:06.000000000 +0900
@@ -337,7 +337,8 @@
struct group *grp;

 rb_secure(4);
  • gid = getgid();
    +/* gid = getgid(); */
  • gid = NUM2INT(id);
    grp = getgrgid(gid);
    if (grp == 0) rb_raise(rb_eArgError, cant find group for %d,
    gid);
    return setup_group(grp)

e$B!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2#N#e#t#w#o#r#ke(B e$B!_e(B
e$B#P#e#o#p#l#e!2e(B
e$B!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1e(B
e$B!!3t<02q<Re(B e$B%M%C%H%U%)%l%9%He(B
e$B!!;v6H?d?J<<e(B Dr.WEB e$BC4Ev!!!e(B e$B!!!e(B e$B?EDe(B
e$BM5G7e(B
e$B!!e(Bhttp://www.netforest.ad.jp/e$B!!!e(B removed_email_address@domain.invalid
e$B!!e(Btel:045-663-6277e$B!!e(Bfax:045-663-6278
e$B!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2e(B
e$B!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1e(B
e$B!!e(Bhttp://www.kamome.or.jp/ <<< ISP FTTH/ADSL/AIR-EDGE/8&16IP
e$B!!e(Bhttp://drweb.jp/e$B!!!e(B <<< e$BM=B,$9$k%%s%A%&%#%k%9e(B


#2

At Thu, 15 Mar 2007 12:36:10 +0900,
wrote:

ruby 1.8.6, 1.8.5-p32 ruby-1.8.5-p12
Etc.getgrgid
(snip)

http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v1_8_5_35/ext/etc/etc.c?r1=10775&r2=11521
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v1_8_6/ext/etc/etc.c?r1=10979&r2=11526

getgrgid() getgid() etc_getgrgid(obj, id)
id

Index: etc.c

etc.c (revision 12068)
+++ etc.c (working copy)
@@ -337,7 +337,7 @@
struct group *grp;

 rb_secure(4);
  • gid = getgid();
  • gid = PW_VAL2GID(id);
    grp = getgrgid(gid);
    if (grp == 0) rb_raise(rb_eArgError, cant find group for %d,
    gid);
    return setup_group(grp);


/
/__ __ Akinori.org / MUSHA.org
/ ) ) ) ) / FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp

Different eyes see different things,
Different hearts beat on different strings
But there are times for you and me when all such things agree


#3

Fri, 16 Mar 2007 17:39:52 +0900 e$B$N%a!<%k$K$F!"e(B
Akinori MUSHA removed_email_address@domain.invalid e$B$5$s$O=q$-$^$7$?e(B :

 struct group *grp;

 rb_secure(4);
  • gid = getgid();
  • gid = PW_VAL2GID(id);
    grp = getgrgid(gid);
    if (grp == 0) rb_raise(rb_eArgError, cant find group for %d, gid);
    return setup_group(grp);

http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=11786
e$B$O5$e(B
e$B$K$7$J$/$F$bNI$$$G$9$+!)e(B

e$B$9$$$^$;$s!"NI$/J,$+$C$F$^$;$s$,e(B


diff -rc ruby-1.8.6/ext/etc/etc.c ruby-1.8.6.patched/ext/etc/etc.c
*** ruby-1.8.6/ext/etc/etc.c Tue Feb 13 08:01:19 2007
ruby-1.8.6.patched/ext/etc/etc.c Fri Mar 16 17:21:42 2007


*** 337,343 ****
struct group *grp;

  rb_secure(4);

! gid = getgid();
grp = getgrgid(gid);
if (grp == 0) rb_raise(rb_eArgError, cant find group for %d,
gid);
return setup_group(grp);
337,343 ----
struct group *grp;

  rb_secure(4);

! gid = NUM2GIDT(id);
grp = getgrgid(gid);
if (grp == 0) rb_raise(rb_eArgError, cant find group for %d,
gid);
return setup_group(grp);
diff -rc ruby-1.8.6/ruby.h ruby-1.8.6.patched/ruby.h
*** ruby-1.8.6/ruby.h Thu Feb 15 11:52:43 2007
ruby-1.8.6.patched/ruby.h Fri Mar 16 17:21:25 2007


*** 163,168 ****
163,187 ----

define OFFT2NUM(v) INT2NUM(v)

#endif

  • #ifndef PIDT2NUM
  • #define PIDT2NUM(v) LONG2NUM(v)
  • #endif
  • #ifndef NUM2PIDT
  • #define NUM2PIDT(v) NUM2LONG(v)
  • #endif
  • #ifndef UIDT2NUM
  • #define UIDT2NUM(v) LONG2NUM(v)
  • #endif
  • #ifndef NUM2UIDT
  • #define NUM2UIDT(v) NUM2LONG(v)
  • #endif
  • #ifndef GIDT2NUM
  • #define GIDT2NUM(v) LONG2NUM(v)
  • #endif
  • #ifndef NUM2GIDT
  • #define NUM2GIDT(v) NUM2LONG(v)
  • #endif
  • #define FIX2LONG(x) RSHIFT((long)x,1)
    #define FIX2ULONG(x) (((unsigned long)(x))>>1)
    #define FIXNUM_P(f) (((long)(f))&FIXNUM_FLAG)

e$B!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2#N#e#t#w#o#r#ke(B e$B!_e(B
e$B#P#e#o#p#l#e!2e(B
e$B!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1e(B
e$B!!3t<02q<Re(B e$B%M%C%H%U%)%l%9%He(B
e$B!!;v6H?d?J<<e(B Dr.WEB e$BC4Ev!!!e(B e$B!!!e(B e$B?EDe(B
e$BM5G7e(B
e$B!!e(Bhttp://www.netforest.ad.jp/e$B!!!e(B removed_email_address@domain.invalid
e$B!!e(Btel:045-663-6277e$B!!e(Bfax:045-663-6278
e$B!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2e(B
e$B!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1e(B
e$B!!e(Bhttp://www.kamome.or.jp/ <<< ISP FTTH/ADSL/AIR-EDGE/8&16IP
e$B!!e(Bhttp://drweb.jp/e$B!!!e(B <<< e$BM=B,$9$k%%s%A%&%#%k%9e(B


#4

e$B?"ED$G$9!#e(B

Fri, 16 Mar 2007 17:39:52 +0900 e$B$N%a!<%k$K$F!"e(B
Akinori MUSHA removed_email_address@domain.invalid e$B$5$s$O=q$-$^$7$?e(B :
:

  • gid = getgid();
  • gid = PW_VAL2GID(id);
    grp = getgrgid(gid);
    if (grp == 0) rb_raise(rb_eArgError, cant find group for %d, gid);
    return setup_group(grp);

e$B$3$A$i$N=$@5$G$bL^O@LdBj$"$j$^$;$s$G$7$?!#e(B

$ for i in 0 1 511; do ruby -r etc -e p Etc.getgrgid($i); done
#<struct Struct::Group name=root, passwd="", gid=0, mem=[root]>
#<struct Struct::Group name=bin, passwd="", gid=1, mem=[root, bin,
daemon]>
#<struct Struct::Group name=ueda, passwd=x, gid=511, mem=[]>

e$B!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2#N#e#t#w#o#r#ke(B e$B!_e(B
e$B#P#e#o#p#l#e!2e(B
e$B!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1e(B
e$B!!3t<02q<Re(B e$B%M%C%H%U%)%l%9%He(B
e$B!!;v6H?d?J<<e(B Dr.WEB e$BC4Ev!!!e(B e$B!!!e(B e$B?EDe(B
e$BM5G7e(B
e$B!!e(Bhttp://www.netforest.ad.jp/e$B!!!e(B removed_email_address@domain.invalid
e$B!!e(Btel:045-663-6277e$B!!e(Bfax:045-663-6278
e$B!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2!2e(B
e$B!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1!1e(B
e$B!!e(Bhttp://www.kamome.or.jp/ <<< ISP FTTH/ADSL/AIR-EDGE/8&16IP
e$B!!e(Bhttp://drweb.jp/e$B!!!e(B <<< e$BM=B,$9$k%%s%A%&%#%k%9e(B


#5

At Fri, 16 Mar 2007 17:49:23 +0900,
wrote:

etc.c (revision 12068)

http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=11786


(patch snipped)



/
/__ __ Akinori.org / MUSHA.org
/ ) ) ) ) / FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp

Different eyes see different things,
Different hearts beat on different strings
But there are times for you and me when all such things agree