home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / perl / scripts-convex / pwbitch < prev    next >
Encoding:
Text File  |  1990-08-24  |  1.3 KB  |  51 lines

  1. #!/usr/local/bin/perl
  2.  
  3. $PIPE = "|/usr/lib/sendmail -oi -t"; 
  4. #$PIPE = "|/bin/cat";
  5.  
  6. $SIG{'PIPE'} = 'plumber';
  7. sub plumber { die "$0: broken PIPE talking to sendmail!\n"; } 
  8.  
  9.  
  10. while (<>) {
  11.     next unless /^Problem/;
  12.     chop;
  13.     split;
  14.     for ( @_ ) { s/.*://; } 
  15.  
  16.     $nullpw =  /null passwd/;
  17.  
  18.     ($user,$host,$passwd) = 
  19.     $nullpw ? ($_[2], $_[3], ' ')
  20.         : ($_[1], $_[2], $_[3]);
  21.  
  22.     printf "user %-8s has passwd %-8s on host %s\n",
  23.     $user, $passwd, $host;
  24.  
  25.     next if $user =~ /uucp/;
  26.  
  27.     open PIPE || die "$0: couldn't open $PIPE: $!\n";
  28.  
  29.     printf PIPE "From: Security Auditor <daemon>\n";
  30.     printf PIPE "To: %s\n",  $user;
  31.  
  32.     if ($nullpw) {
  33.     printf PIPE "Subject: Your missing passwd on %s\n\n", $host;
  34.  
  35.     printf PIPE "On the machine named \"%s\", your password has not\n",
  36.         $host;
  37.     printf PIPE "yet been set.  This lets anyone login as you without\n";
  38.     printf PIPE "having to present  password, so please try to\n";
  39.     } else {
  40.     printf PIPE "Subject: Your trivial passwd on %s\n\n", $host;
  41.  
  42.     printf PIPE "On the machine named \"%s\", your passwd is \"%s\".\n",
  43.         $host, $passwd;
  44.     printf PIPE "This is considered very easy to guess, so please\n";
  45.     }
  46.     printf PIPE "fix it at your earliest possible convenience.\n";
  47.     printf PIPE "\nOtherwise your account may soon be de-activated!\n";
  48.     printf PIPE "\nThanks,\n\n--daemon\n";
  49.     close PIPE;
  50.