Etc.getgrgid returns root always! $ irb irb(main):001:0> require 'etc' => true irb(main):002:0> Etc.getgrgid(37) => #<struct Struct::Group name="root", passwd="x", gid=0, mem=["root"]> $ rpm -q ruby ruby-1.8.5.35-2.fc6
Looking at the code it is obvious why it doesn't work. static VALUE etc_getgrgid(obj, id) VALUE obj, id; { #ifdef HAVE_GETGRENT gid_t gid; struct group *grp; rb_secure(4); gid = getgid(); grp = getgrgid(gid); if (grp == 0) rb_raise(rb_eArgError, "can't find group for %d", gid); return setup_group(grp); #else return Qnil; #endif }
The attached patch, which reverts Etc::getgrgid to what's in both the 1.8.5 and 1.8.6 branches (no idea what happened with p35), seems to work .. at least on i386 .. at least with the very simple test of ruby -retc -e 'p Etc::getgrgid(1)' #<struct Struct::Group name="bin", passwd="x", gid=1, mem=["root", "bin", "daemon"]>
Created attachment 152729 [details] Patch promised in #3
Created attachment 152730 [details] Trivial patch for spec file Patch for ruby.spec
Looks like this bug has been fixed in Ruby SVN as well: http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ext/etc/etc.c?view=log#rev12071 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v1_8_5_39/ext/etc/etc.c?r1=11708&r2=12079&view=patch
Thanks for certain info.
Fixed in 1.8.5.52-1.fc6. sorry for taking a long time for this bug.