Skip Menu |

This queue is for tickets about the Passwd-Unix-Alt CPAN distribution.

Report information
The Basics
Id: 78414
Status: resolved
Priority: 0/
Queue: Passwd-Unix-Alt

People
Owner: Nobody in particular
Requestors: AGORMAN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: 0.5211



I believe there is a bug in the maxgid method. It returns that maximum primary group from the /etc/passwd file. From the methods documentation I expected it to return the max gid from the /etc/group file. A group in the groups file may not be a primary group in the passwd file so the current implementation won't necessarily get the max gid present in the system. I've included a patch that I believe fixes the issue. Thank you, Andy
Subject: Passwd-Unix-Alt.patch
--- /opt/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Passwd/Unix/Alt.pm 2012-07-16 13:38:41.000000000 -0700 +++ Alt.pm 2012-07-16 13:38:22.000000000 -0700 @@ -565,9 +565,9 @@ sub maxgid { my $self = scalar @_ && ref $_[0] eq __PACKAGE__ ? shift : $Self; my $max = 0; - open(my $fh, '<', $self->passwd_file()) or do { $errstr = "Can't open passwd file ".$self->passwd_file.": $! (".__FILE__." line ".__LINE__.")"; return }; + open(my $fh, '<', $self->group_file()) or do { $errstr = "Can't open passwd file ".$self->passwd_file.": $! (".__FILE__." line ".__LINE__.")"; return }; while(<$fh>){ - my $tmp = (split(/:/,$_))[3]; + my $tmp = (split(/:/,$_))[2]; $max = $tmp > $max ? $tmp : $max; } close($fh);
On Mon Jul 16 17:02:18 2012, AGORMAN wrote: Show quoted text
> I believe there is a bug in the maxgid method. It returns that maximum > primary group from the /etc/passwd file. From the methods
documentation Show quoted text
> I expected it to return the max gid from the /etc/group file. A group
in Show quoted text
> the groups file may not be a primary group in the passwd file so the > current implementation won't necessarily get the max gid present in
the Show quoted text
> system. I've included a patch that I believe fixes the issue. > > Thank you, > > Andy
Hi Andy, You're correct. Fixed (+ test case). Released 0.5212. Thanks, Steven