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);