Mailing List Archive

Bug in find2perl with "-user nonexistentuser"
*** Trying again --- This patch, unlike the last one, actually FINDS
*** files owned by nonexistent UIDs as well as NOT FINDING root-owned
*** files in that case!

---------------------------------------------------------------------------
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's no doubt a nicer way. :-)
There's somehing unappealing about using the string comparison, but it had
to work for UIDs, not in the password database, expressed as either numbers
or names.

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

***************************************************************************
*** find2perl-dist Sat Jul 1 12:03:02 1995
--- find2perl Sat Sep 16 07:00:43 1995
***************
*** 73,77 ****
elsif ($_ eq 'user') {
$uname = shift;
! $out .= &tab . "(\$uid == \$uid{'$uname'})";
$inituser++;
}
--- 73,78 ----
elsif ($_ eq 'user') {
$uname = shift;
! $out .= &tab .
! "(\$uid eq (defined(\$uid{'$uname'}) ? \$uid{'$uname'} : '$uname'))";
$inituser++;
}
***************
*** 78,82 ****
elsif ($_ eq 'group') {
$gname = shift;
! $out .= &tab . "(\$gid == \$gid{'$gname'})";
$initgroup++;
}
--- 79,84 ----
elsif ($_ eq 'group') {
$gname = shift;
! $out .= &tab .
! "(\$gid eq (defined(\$gid{'$gname'}) ? \$gid{'$gname'} : '$gname'))";
$initgroup++;
}