Mailing List Archive

Bug in find2perl with "-user nonexistentuser"
The find2perl distributed with 5.001m finds files owned by "root" if you
use something like:
find2perl . -user buxtehude -print
or
find2perl . -user 95010 -print
and the designated user does not exist in the password database. The same
problem occurs with "-group". The problem is that find2perl does a numeric
comparison like "$uid == $uid{$uname}" which evaluates true if $uid == 0
and $uid{$uname} is undefined.

The following patch fixes the problem. There may be a better way; this was
the first that came to mind.

pete peterson
rep@genrad.com
(508)287-7478; Home: (508)256-5829 (Chelmsford, MA)


---------------------------------------------------------------------------
thor% diff -c2 find2perl-dist find2perl
*** find2perl-dist Sat Jul 1 12:03:02 1995
--- find2perl Fri Sep 15 13:31:40 1995
***************
*** 73,77 ****
elsif ($_ eq 'user') {
$uname = shift;
! $out .= &tab . "(\$uid == \$uid{'$uname'})";
$inituser++;
}
--- 73,78 ----
elsif ($_ eq 'user') {
$uname = shift;
! $out .= &tab .
! "(defined(\$uid{'$uname'}) && (\$uid == \$uid{'$uname'}))";
$inituser++;
}
***************
*** 78,82 ****
elsif ($_ eq 'group') {
$gname = shift;
! $out .= &tab . "(\$gid == \$gid{'$gname'})";
$initgroup++;
}
--- 79,84 ----
elsif ($_ eq 'group') {
$gname = shift;
! $out .= &tab .
! "(defined(\$gid{'$gname'}) && (\$gid == \$gid{'$gname'}))";
$initgroup++;
}