Bug 236647 - Etc.getgrgid broken?
Etc.getgrgid broken?
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: ruby (Show other bugs)
6
All Linux
medium Severity medium
: ---
: ---
Assigned To: Akira TAGOH
Bill Huang
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-04-16 18:39 EDT by Kostas Georgiou
Modified: 2007-11-30 17:12 EST (History)
2 users (show)

See Also:
Fixed In Version: 1.8.5.52-1.fc6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-09-10 17:50:36 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch promised in #3 (388 bytes, text/x-patch)
2007-04-16 20:35 EDT, David Lutterkort
no flags Details
Trivial patch for spec file (1.06 KB, patch)
2007-04-16 20:39 EDT, David Lutterkort
no flags Details | Diff

  None (edit)
Description Kostas Georgiou 2007-04-16 18:39:11 EDT
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
Comment 1 Kostas Georgiou 2007-04-16 20:07:58 EDT
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
}
Comment 2 David Lutterkort 2007-04-16 20:34:07 EDT
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"]>
Comment 3 David Lutterkort 2007-04-16 20:35:28 EDT
Created attachment 152729 [details]
Patch promised in #3
Comment 4 David Lutterkort 2007-04-16 20:39:18 EDT
Created attachment 152730 [details]
Trivial patch for spec file

Patch for ruby.spec
Comment 6 Akira TAGOH 2007-04-17 05:46:41 EDT
Thanks for certain info.
Comment 7 Akira TAGOH 2007-06-20 23:05:49 EDT
Fixed in 1.8.5.52-1.fc6. sorry for taking a long time for this bug.

Note You need to log in before you can comment on or make changes to this bug.