X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/38e51db0fc5b2cfb88a193e16a3f9a7c2246ac8a..6bf59599ecd9e30e91c5eefa22472ee080315c30:/onak-mail.pl?ds=sidebyside diff --git a/onak-mail.pl b/onak-mail.pl index 841d4ee..e5c0d04 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,10 +6,11 @@ # Copyright 2002 Project Purple # Released under the GPL. # -# $Id: onak-mail.pl,v 1.7 2003/09/28 17:25:40 noodles Exp $ +# $Id: onak-mail.pl,v 1.9 2004/01/04 18:48:37 noodles Exp $ # use strict; +use Fcntl ':flock'; use IPC::Open3; my %config; @@ -39,6 +39,8 @@ sub readconfig { $config{'mta'} = $1; } elsif (/^pks_bin_dir (.*)/) { $config{'pks_bin_dir'} = $1; + } elsif (/^db_dir (.*)/) { + $config{'db_dir'} = $1; } elsif (/^syncsite (.*)/) { push @{$config{'syncsites'}}, $1; } @@ -60,13 +62,22 @@ sub submitupdate { my @data = @_; my (@errors, @mergedata); + open(LOCKFILE, '>'.$config{'db_dir'}.'/onak-mail.lck'); + flock(LOCKFILE, LOCK_EX); + print LOCKFILE "$$"; + open3(\*MERGEIN, \*MERGEOUT, \*MERGEERR, $config{'pks_bin_dir'}."/onak", "-u", "add"); print MERGEIN @data; close MERGEIN; @mergedata = ; + close MERGEOUT; @errors = ; + close MERGEERR; + + flock(LOCKFILE, LOCK_UN); + close(LOCKFILE); return @mergedata; } @@ -95,6 +106,9 @@ while (<>) { push @body, $_; } } +if (! defined($replyto)) { + $replyto = $from; +} # HELP, ADD, INCREMENTAL, VERBOSE INDEX , INDEX , GET , # LAST @@ -156,7 +170,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; }