Skip to content

Commit 4ef9c6d

Browse files
authored
id: gid 0 is valid (#715)
* Previously commit 92678da was added to allow resolving "root" to uid 0 * When testing -g option a similar issue was discovered (gid of 0 was being treated as a failure of getpwnam) * This was discovered while testing against id on my Linux system %grep '^root' /etc/group root:x:0: %/usr/bin/id -g root 0 %perl id -g root # before patch 1000
1 parent 0c8e2af commit 4ef9c6d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bin/id

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if ( $opt_u ) { # print uid
4545
$tp = scalar getpwuid $tp || $tp if ( $opt_n );
4646
}
4747
elsif ( $opt_g ) { # print gid
48-
$tp = ($gid)?$gid:(split(/\s+/,($opt_r)?$(:$)))[0];
48+
$tp = defined $gid ? $gid : (split(/\s+/,($opt_r)?$(:$)))[0];
4949
$tp = scalar getgrgid $tp || $tp if ( $opt_n );
5050
}
5151
elsif ( $opt_p ) { # human-readable form (names when possible, etc.)

0 commit comments

Comments
 (0)