3 # $RCSfile: scanner,v $$Revision: 4.1 $$Date: 92/08/07 17:20:44 $
5 # This runs all the scan_* routines on all the machines in /etc/ghosts.
6 # We run this every morning at about 6 am:
10 # decrypt scanner | perl >scan.out 2>&1
11 # mail admin <scan.out
13 # Note that the scan_* files should be encrypted with the key "-inquire", and
14 # scanner should be encrypted somehow so that people can't find that key.
15 # I leave it up to you to figure out how to unencrypt it before executing.
17 $ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/usr/ucb:.';
19 $| = 1; # command buffering on stdout
21 print "Subject: bizarre happenings\n\n";
23 (chdir '/usr/adm/private') || die "Can't cd to /usr/adm/private: $!\n";
28 @scanlist = split(/[ \t\n]+/,`echo scan_*`);
31 scan: while ($scan = shift(@scanlist)) {
32 print "\n********** $scan **********\n";
37 open(ghosts, '/etc/ghosts') || die 'No /etc/ghosts file';
39 $one_of_these = ":$systype:";
40 if ($systype =~ s/\+/[+]/g) {
41 $one_of_these =~ s/\+/:/g;
44 line: while (<ghosts>) {
49 if (/^([a-zA-Z_0-9]+)=(.+)/) {
50 $name = $1; $repl = $2;
52 $one_of_these =~ s/:$name:/:$repl:/;
57 if ($showhost) { $showhost = "$host:\t"; }
58 class: while ($class = pop(gh)) {
59 if (index($one_of_these,":$class:") >=0) {
61 `exec crypt -inquire <$scan >.x 2>/dev/null`;
62 unless (open(scan,'.x')) {
63 print "Can't run $scan: $!\n";
67 unless ($cmd =~ s/#!(.*)\n/$1/) {
68 $cmd = '/usr/bin/perl';
71 if (open(PIPE,"exec rsh $host '$cmd' <.x|")) {
75 last if $iter++ > 1000; # must be looping
76 next if /^[0-9.]+u [0-9.]+s/;
81 print "(Can't execute rsh: $!)\n";