4 # onak-mail.pl - Mail processing interface for onak, an OpenPGP Keyserver.
6 # Written by Jonathan McDowell <noodles@earth.li>
7 # Copyright 2002 Project Purple
8 # Released under the GPL.
19 # Reads in our config file. Ignores any command it doesn't understand rather
20 # than having to list all the ones that are of no interest to us.
24 open(CONFIG, "/home/noodles/projects/onak/onak.conf") or
25 die "Can't read config file: $!";
29 # Ignore; comment line.
30 } elsif (/^this_site (.*)/) {
31 $config{'thissite'} = $1;
32 } elsif (/^maintainer_email (.*)/) {
33 $config{'adminemail'} = $1;
34 } elsif (/^mail_delivery_client (.*)/) {
36 } elsif (/^syncsite (.*)/) {
37 push @{$config{'syncsites'}}, $1;
49 # Takes an armored OpenPGP stream and submits it to the keyserver. Returns the
50 # difference between what we just added and what we had before (ie the least
51 # data need to get from what we had to what we have).
55 my (@errors, @mergedata);
57 open3(\*MERGEIN, \*MERGEOUT, \*MERGEERR,
58 "/home/noodles/onak-0.0.3/onak", "-u", "add");
63 @mergedata = <MERGEOUT>;
65 open (LOG, ">>/home/noodles/onak-0.0.3/keyadd.log");
66 print LOG "[".localtime(time)."] ", @errors;
72 my ($inheader, %seenby, $subject, $from, $replyto, @body, @syncmail);
80 if (/^Subject:\s*(.*)\s*$/i) {
82 } elsif (/^X-KeyServer-Sent:\s*(.*)\s*$/i) {
84 } elsif (/^From:\s*(.*)\s*$/i) {
86 } elsif (/^Reply-To:\s*(.*)\s*$/i) {
97 # HELP, ADD, INCREMENTAL, VERBOSE INDEX <keyid>, INDEX <keyid>, GET <keyid>,
100 if ($subject =~ /^INCREMENTAL$/i) {
104 my @newupdate = submitupdate(@body);
107 foreach $i (@{$config{'syncsites'}}) {
108 if (! defined($seenby{$i})) {
113 open (LOG, ">>/home/noodles/logs/keyadd.log");
114 print LOG "[".localtime(time)."] Syncing with $count sites.\n";
117 if ($newupdate[0] eq '') {
118 open (LOG, ">>/home/noodles/logs/keyadd.log");
119 print LOG "[".localtime(time)."] Nothing to sync.\n";
125 open(MAIL, "|$config{mta}");
126 print MAIL "From: $config{adminemail}\n";
128 foreach $i (@{$config{'syncsites'}}) {
129 if (! defined($seenby{$i})) {
138 print MAIL "Subject: incremental\n";
139 foreach $site (keys %seenby) {
140 print MAIL "X-KeyServer-Sent: $site\n";
142 print MAIL "X-KeyServer-Sent: $config{thissite}\n";
143 print MAIL "Precedence: list\n";
144 print MAIL "MIME-Version: 1.0\n";
145 print MAIL "Content-Type: application/pgp-keys\n";