X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=onak-mail.pl;h=1c3647c9720f6493393cda7f1f031abf40b8d181;hb=f5f103192a4105438bee90bbf85e7407f73b49ca;hp=3076a7e99a72f44feddc30baa8f482292020b51c;hpb=0f9e9f98538575cf98f55699962d605caa9567f0;p=onak.git diff --git a/onak-mail.pl b/onak-mail.pl index 3076a7e..1c3647c 100755 --- a/onak-mail.pl +++ b/onak-mail.pl @@ -1,5 +1,4 @@ #!/usr/bin/perl -w - # # onak-mail.pl - Mail processing interface for onak, an OpenPGP Keyserver. # @@ -7,6 +6,8 @@ # Copyright 2002 Project Purple # Released under the GPL. # +# $Id: onak-mail.pl,v 1.8 2003/10/11 22:17:17 noodles Exp $ +# use strict; use IPC::Open3; @@ -29,10 +30,14 @@ sub readconfig { # Ignore; comment line. } elsif (/^this_site (.*)/) { $config{'thissite'} = $1; + } elsif (/^logfile (.*)/) { + $config{'logfile'} = $1; } elsif (/^maintainer_email (.*)/) { $config{'adminemail'} = $1; } elsif (/^mail_delivery_client (.*)/) { $config{'mta'} = $1; + } elsif (/^pks_bin_dir (.*)/) { + $config{'pks_bin_dir'} = $1; } elsif (/^syncsite (.*)/) { push @{$config{'syncsites'}}, $1; } @@ -55,16 +60,14 @@ sub submitupdate { my (@errors, @mergedata); open3(\*MERGEIN, \*MERGEOUT, \*MERGEERR, - "/home/noodles/onak-0.0.3/onak", "-u", "add"); + $config{'pks_bin_dir'}."/onak", "-u", "add"); print MERGEIN @data; close MERGEIN; @mergedata = ; + close MERGEOUT; @errors = ; - - open (LOG, ">>/home/noodles/onak-0.0.3/keyadd.log"); - print LOG "[".localtime(time)."] ", @errors; - close LOG; + close MERGEERR; return @mergedata; } @@ -93,6 +96,9 @@ while (<>) { push @body, $_; } } +if (! defined($replyto)) { + $replyto = $from; +} # HELP, ADD, INCREMENTAL, VERBOSE INDEX , INDEX , GET , # LAST @@ -102,6 +108,7 @@ if ($subject =~ /^INCREMENTAL$/i) { my $count; my $i; my @newupdate = submitupdate(@body); + my @time; $count = 0; foreach $i (@{$config{'syncsites'}}) { @@ -110,13 +117,22 @@ if ($subject =~ /^INCREMENTAL$/i) { } } - open (LOG, ">>/home/noodles/logs/keyadd.log"); - print LOG "[".localtime(time)."] Syncing with $count sites.\n"; + open (LOG, ">>$config{'logfile'}"); + @time = localtime(time); + print LOG "["; + print LOG sprintf "%02d/%02d/%04d %02d:%02d:%02d", + $time[3], $time[4] + 1, $time[5] + 1900, + $time[2], $time[1], $time[0]; + print LOG "] onak-mail[$$]: Syncing with $count sites.\n"; close LOG; - if ($newupdate[0] eq '') { - open (LOG, ">>/home/noodles/logs/keyadd.log"); - print LOG "[".localtime(time)."] Nothing to sync.\n"; + if ((! defined($newupdate[0])) || $newupdate[0] eq '') { + open (LOG, ">>$config{'logfile'}"); + print LOG "["; + print LOG sprintf "%02d/%02d/%04d %02d:%02d:%02d", + $time[3], $time[4] + 1, $time[5] + 1900, + $time[2], $time[1], $time[0]; + print LOG "] onak-mail[$$]: Nothing to sync.\n"; close LOG; $count = 0; } @@ -144,7 +160,34 @@ if ($subject =~ /^INCREMENTAL$/i) { print MAIL "MIME-Version: 1.0\n"; print MAIL "Content-Type: application/pgp-keys\n"; print MAIL "\n"; - print @newupdate; + print MAIL @newupdate; close MAIL; } +} elsif ($subject =~ /^(VERBOSE )?INDEX (.*)$/i) { + my (@indexdata, $command); + + $command = "index"; + if (defined($1)) { + $command = "vindex"; + } + + open3(\*INDEXIN, \*INDEXOUT, \*INDEXERR, + $config{'pks_bin_dir'}."/onak", $command, "$2"); + close INDEXIN; + @indexdata = ; + close INDEXOUT; + close INDEXERR; + + open(MAIL, "|$config{mta}"); + print MAIL "From: $config{adminemail}\n"; + print MAIL "To: $replyto\n"; + print MAIL "Subject: Reply to INDEX $2\n"; + print MAIL "Precedence: list\n"; + print MAIL "MIME-Version: 1.0\n"; + print MAIL "Content-Type: text/plain\n"; + print MAIL "\n"; + print MAIL "Below follows the reply to your recent keyserver query:\n"; + print MAIL "\n"; + print MAIL @indexdata; + close MAIL; }