#!/local/bin/perl $PATH = "/local/bin:/bin"; $ENV{IFS} = ""; use strict; use File::Find; use Getopt::Std; use vars qw ( $FILELIST $FSLIST $SKIPLIST @SKIPS %KEEP $VERBOSE $ECHO $opt_n); $FILELIST = "/usr/local/etc/unsuid.keep"; $FSLIST = "/usr/local/etc/unsuid.fslist"; $SKIPLIST = "/usr/local/etc/unsuid.skip"; sub wanted { my ($dev,$ino,$mode,$nlink,$uid,$gid); my $pathname = $File::Find::dir . "/" . $_; (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && !($File::Find::prune |= ($dev != $File::Find::topdev)) && -f _ && (($mode & 04000) == 04000) && ($uid == $File::Find::uid{'root'}) && do { foreach my $skip (@SKIPS) { return if ($File::Find::dir =~ /$skip/); } if ($ECHO) { $KEEP{$pathname} ? print "Should NOT chmod u-s $pathname\n" : print "Should chmod u-s $pathname\n"; } else { system("/bin/chmod u-s $pathname") unless $KEEP{$pathname}; } }; } Main(); sub Main { getopts("n"); ($opt_n) && ($ECHO = 1); open(FILELIST, "$FILELIST") || die "file '$FILELIST' : $!"; my @filelist = ; chomp(@filelist); close(FILELIST); open(FSLIST, "$FSLIST") || die "file '$FSLIST' : $!"; my @fslist = ; chomp(@fslist); close(FSLIST); open(SKIPLIST, "$SKIPLIST") || die "file '$SKIPLIST' : $!"; @SKIPS = ; chomp(@SKIPS); close(SKIPLIST); foreach my $file (@filelist) { $KEEP{$file} = 1; } foreach my $fs (@fslist) { File::Find::find(\&wanted , $fs); } }