home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / perl / scripts-convex / audit / tchrist.audit_mail.pl < prev    next >
Encoding:
Perl Script  |  1993-07-14  |  2.0 KB  |  103 lines

  1. #!/usr/local/bin/perl
  2.  
  3. unshift(@INC, "/mnt/tchrist/scripts/deliverlib");
  4.  
  5. @pw = getpwuid($<);
  6.  
  7. require 'audit.pl';
  8. require 'mh.pl';
  9.  
  10. &initialize();
  11.  
  12. $HOME = $ENV{HOME}
  13.      || $ENV{LOGDIR}
  14.      || $pw[7]
  15.      || die "No home directory";
  16.  
  17. $USER = $ENV{USER}
  18.      || $ENV{LOGNAME}
  19.      || $pw[0]
  20.      || die "Cannot determine user for id $>";
  21.  
  22.  
  23. &mh_profile();
  24.  
  25. $maildrops = $MH{'path'} . '/in.coming';
  26.  
  27.  
  28. if ($subject =~ /\b(fuck|shit|damn)\b/) {
  29.     require 'sysexits.ph';
  30.     print STDERR <<EOF;
  31.  
  32. I'm sorry, $friendly, but I simply refuse to tolerate 
  33. such language as $1.  When you can send me nice mail, 
  34. my inbox will then accept your mail again.
  35.  
  36. --tom
  37. EOF
  38.     exit &EX_UNAVAILABLE;
  39.  
  40. # avoid duplicate messages, which are defined as 
  41. # having the same subject, body length, body checksum,
  42. # and received with 10 minutes of each other.
  43. local($db) = "$MH{'path'}/.dupmsgdb";
  44. if (dbmopen(Msgs, $db, 0644)) {
  45.     local($sum) = unpack("%31C*", $body);
  46.     local($len) = length($body);
  47.     if ($Msgs{$subject, $len, $sum} + 10*60 > time) {
  48.     warn "duplicate message discarded";
  49.     exit; # duplicate
  50.     } else {
  51.     $Msgs{$subject, $len, $sum} = time;
  52.     } 
  53.     dbmclose(%Msgs);
  54.  
  55.  
  56. #if ($from =~ /MAILER/ || ($from eq $USER  && $subject =~  /send failed on enclosed draft/) ) { 
  57.     #warn "mailer daemon message";
  58.     #&deliver(); 
  59.     #exit; 
  60. #};
  61.  
  62. # kill any mail to 'x' aliases 
  63. if (grep(/^x(.*)/ && (gethostbyname($1))[0], @to, @cc)) {
  64.     # &rcvstore( "junk" );
  65.     warn "disarding xhost message";
  66.     exit;
  67. }
  68.  
  69. $organization = "convex" if 
  70.     $organization eq "local" && (getpwnam($from))[0];
  71.  
  72.  
  73. if (grep(/\bbod/,@to,@cc)) {
  74.     &rcvstore("usenix/bod");
  75.  
  76. for (@to, @cc) {
  77.     if (/sage-([^,\s]+)/) {
  78.     warn "sage message";
  79.     &rcvstore("sage/$1");
  80.     last;
  81.     } 
  82.  
  83. # default handling for mail addressed directly to me
  84. if (grep(/^$USER\b/o, @to, @cc)) { 
  85.     warn "message for ME";
  86.     # &vacation();
  87.     &deposit("$maildrops/personal");
  88.     exit;
  89. }
  90.  
  91.  
  92. # this mail was not sent to me directly, so don't answer with vacation mail,
  93. # but do everything else.
  94. #
  95.  
  96. &deposit("$maildrops/lists");
  97.  
  98. exit;
  99.