Current Path : /compat/linux/proc/68247/root/compat/linux/proc/68247/root/compat/linux/proc/3760/cwd/home/mf/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //compat/linux/proc/68247/root/compat/linux/proc/68247/root/compat/linux/proc/3760/cwd/home/mf/autorep |
#!/usr/bin/perl -w # # autorep # #// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #// use Module #// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= use strict; use vars qw( $opt_t $opt_h $opt_l $opt_d %secrets ); use Getopt::Long; use DB_File; use Fcntl; use Jcode; use ADN::MailParse; use ADN::Utility; #// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #// Controller #// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #// ---------------------------------------------------------- #// Option Parse #// ---------------------------------------------------------- $opt_t = ''; $opt_h = ''; $opt_l = 0; $opt_d = ''; my @basename = split(/\//, $0); my $basename = pop(@basename); my $result = GetOptions('t=s','h=s','l','d=s'); if ($opt_t eq '' || $opt_h eq '') { print "usage: $basename -t [timer (hour)] -h [/home/cust_id/dom_name/user]\n"; print " -t => *must* option.\n"; print " -h => *must* option.\n"; print " -l => maddr, reply time listing\n"; exit; } $opt_h =~ s/\/$//; unless ($opt_h =~ /^\/home\/cs(\d{5})/) { print "$opt_h seems to strange path.\n"; exit; } unless ( -e $opt_h ) { print "$opt_h does not exist.\n"; exit; } my $file0 = $opt_h . '/.mf/autorep.msg'; my $file1 = $opt_h . '/.mf/autorep.db'; unless ( -e $file0 ) { print "$file0 does not exist.\n"; exit; } #// -------------------------------------------------------------- #// Start #// -------------------------------------------------------------- #// DB my $dbh = tie (%secrets, "DB_File", $file1, O_RDWR|O_CREAT, 0600); #// Show Reply Status if ($opt_l == 1) { foreach (sort {$secrets{$a} <=> $secrets{$b}} (keys %secrets)) { print ADN::Utility::utime2date($secrets{$_}) . "\t$_\n"; } undef $dbh; untie %secrets; exit; } #// Parse Mail my @mail = (); foreach (<STDIN>) { push(@mail, $_); } my $parse = new ADN::MailParse(); my @header0 = qw( To Cc Precedence Auto-Submitted Subject ); my @header = $parse->header(@header0, \@mail); my @from = split(/ /, $mail[0]); my $from = $from[1]; my $to = $header[0]; my $cc = $header[1]; my $prec = $header[2]; my $auto = $header[3]; my @path = split(/\//, $opt_h); my $maddr = $path[4] . '@' . $path[3]; #// Check Timer my $last = $secrets{$from}; unless ($last) { $last = 0; } my $time0 = time(); my $time1 = $last + ($opt_t * 60 * 60); if ($time0 < $time1) { undef $dbh; untie %secrets; exit; } #// Check Header my $reply = 1; if ($auto ne '') { $reply = 0; } if ($from =~ /-request\@/i || $from =~ /-relay\@/i || $from =~ /-owner\@/i || $from =~ /owner-(.+)\@/i || $from =~ /-approval\@/i || $from =~ /postmaster\@/i || $from =~ /uucp\@/i || $from =~ /mailer\@/i || $from =~ /^mailer-daemon/i) { $reply = 0; } if ($prec eq 'bulk' || $prec eq 'list') { $reply = 0; } if ($reply == 1) { unless ($to =~ /$maddr/) { $reply = 0; } if ($cc ne '') { if ($cc =~ /$maddr/) { $reply = 1; } else { $reply = 0; } } } #// Reply if ($reply == 1) { my $tml = <<"TML"; Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Auto-Submitted: auto-replied From: $maddr To: $from TML $tml .= `/bin/cat $file0`; my $mta = "/usr/local/sbin/sendmail -f$maddr $from"; if ($opt_d) { $tml .= "\n" . $header[4]; $mta = "/usr/local/sbin/sendmail -f$maddr $opt_d"; } open MAIL, "| $mta"; print MAIL Jcode::convert($tml, 'jis'); $secrets{$from} = $time0; } undef $dbh; untie %secrets; #// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #// Model #// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=