develooper Front page | perl.perl5.porters | Postings from July 2005

[perl #9565] [PATCH] /op/groups.t bug

Thread Next
From:
Steve Peters via RT
Date:
July 13, 2005 06:51
Subject:
[perl #9565] [PATCH] /op/groups.t bug
Message ID:
rt-3.0.11-9565-117185.14.6331240065229@perl.org
> [stmpeters - Tue Jul 05 13:19:42 2005]:
> 
> > [jhpb@hekimian.com - Fri Mar 07 11:03:22 2003]:
> >
> > This is a bug report for perl from jhpb@hekimian.com,
> > generated with the help of perlbug 1.34 running under perl v5.8.0.
> >
> >
> > -----------------------------------------------------------------
> > [Please enter your report here]
> >
> > The regression test fails with:
> >
> > 	t/op/grep............................ok
> > 	t/op/groups..........................FAILED at test 1
> > 	t/op/gv..............................ok
> >
> > Here is more detailed output from t/op/groups:
> >
> > 	# ./perl op/groups.t
> > 	# groups = uid=0(root) gid=0(root)
> >
>
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),2015(releases),1(bin)
> > 	#
> >
>
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),2015(releases),1(bin)
> > 	# g0 = 0(root) 1(bin) 2(daemon) 3(sys) 4(adm) 6(disk) 10(wheel)
> >    2015(releases) 1(bin)
> > 	# g1 = root bin daemon sys adm disk wheel releases bin
> > 	1..2
> > 	# pwgid = 0, pwgnam = root
> > 	# gr = bin releases wheel disk adm sys daemon bin
> > 	#gr1 is <adm bin bin daemon disk releases sys wheel>
> > 	#gr2 is <adm bin daemon disk releases sys wheel>
> > 	not ok 1
> > 	ok 2
> >
> > I think the problem may be due to a duplicate entry in our NIS
> > /etc/group map.  We have two groups with ID 1, but with different
> > names.  One of the names is "bin".
> >
> 
> I was able to reproduce this bug, although, only while root.  Anyways,
> the test does make poor assumptions about the correctness of the data
> in
> /etc/group.  Patch forthcoming.
> 
> 

The problem here is that users can have duplicate group numbers or names
in /etc/group.  The attached patch will uniquely sort the group names
for comparisons.

--- t/op/groups.t.old   2005-01-21 09:52:53.000000000 -0600
+++ t/op/groups.t       2005-07-13 08:26:49.000000000 -0500
@@ -137,7 +137,9 @@
        # Or anybody else who can have spaces in group names.
        $gr1 = join(' ', grep(!$did{$_}++, sort split(' ', join(' ',
@gr))));
 } else {
-       $gr1 = join(' ', sort @gr);
+        # Don't assume that there aren't duplicate groups
+        my %seen;
+       $gr1 = join(' ', sort grep defined $_ && !$seen{$_}++, @gr);
 }


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About