Bug 236647 - Etc.getgrgid broken?
Summary: Etc.getgrgid broken?
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: ruby (Show other bugs)
(Show other bugs)
Version: 6
Hardware: All Linux
medium
medium
Target Milestone: ---
Assignee: Akira TAGOH
QA Contact: Bill Huang
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-04-16 22:39 UTC by Kostas Georgiou
Modified: 2007-11-30 22:12 UTC (History)
2 users (show)

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 21:50:36 UTC
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-17 00:35 UTC, David Lutterkort
no flags Details
Trivial patch for spec file (1.06 KB, patch)
2007-04-17 00:39 UTC, David Lutterkort
no flags Details | Diff

Description Kostas Georgiou 2007-04-16 22:39:11 UTC
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-17 00:07:58 UTC
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-17 00:34:07 UTC
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-17 00:35:28 UTC
Created attachment 152729 [details]
Patch promised in #3

Comment 4 David Lutterkort 2007-04-17 00:39:18 UTC
Created attachment 152730 [details]
Trivial patch for spec file

Patch for ruby.spec

Comment 6 Akira TAGOH 2007-04-17 09:46:41 UTC
Thanks for certain info.

Comment 7 Akira TAGOH 2007-06-21 03:05:49 UTC
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.