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.
10 # $Id: onak-mail.pl,v 1.6 2003/06/04 20:57:11 noodles Exp $
21 # Reads in our config file. Ignores any command it doesn't understand rather
22 # than having to list all the ones that are of no interest to us.
26 open(CONFIG, "/home/noodles/projects/onak/onak.conf") or
27 die "Can't read config file: $!";
31 # Ignore; comment line.
32 } elsif (/^this_site (.*)/) {
33 $config{'thissite'} = $1;
34 } elsif (/^maintainer_email (.*)/) {
35 $config{'adminemail'} = $1;
36 } elsif (/^mail_delivery_client (.*)/) {
38 } elsif (/^syncsite (.*)/) {
39 push @{$config{'syncsites'}}, $1;
51 # Takes an armored OpenPGP stream and submits it to the keyserver. Returns the
52 # difference between what we just added and what we had before (ie the least
53 # data need to get from what we had to what we have).
57 my (@errors, @mergedata);
59 open3(\*MERGEIN, \*MERGEOUT, \*MERGEERR,
60 "/home/noodles/onak-0.0.3/onak", "-u", "add");
64 @mergedata = <MERGEOUT>;
67 open (LOG, ">>/home/noodles/onak-0.0.3/keyadd.log");
68 print LOG "[".localtime(time)."] ", @errors;
74 my ($inheader, %seenby, $subject, $from, $replyto, @body, @syncmail);
82 if (/^Subject:\s*(.*)\s*$/i) {
84 } elsif (/^X-KeyServer-Sent:\s*(.*)\s*$/i) {
86 } elsif (/^From:\s*(.*)\s*$/i) {
88 } elsif (/^Reply-To:\s*(.*)\s*$/i) {
99 # HELP, ADD, INCREMENTAL, VERBOSE INDEX <keyid>, INDEX <keyid>, GET <keyid>,
102 if ($subject =~ /^INCREMENTAL$/i) {
106 my @newupdate = submitupdate(@body);
109 foreach $i (@{$config{'syncsites'}}) {
110 if (! defined($seenby{$i})) {
115 open (LOG, ">>/home/noodles/logs/keyadd.log");
116 print LOG "[".localtime(time)."] Syncing with $count sites.\n";
119 if ($newupdate[0] eq '') {
120 open (LOG, ">>/home/noodles/logs/keyadd.log");
121 print LOG "[".localtime(time)."] Nothing to sync.\n";
127 open(MAIL, "|$config{mta}");
128 print MAIL "From: $config{adminemail}\n";
130 foreach $i (@{$config{'syncsites'}}) {
131 if (! defined($seenby{$i})) {
140 print MAIL "Subject: incremental\n";
141 foreach $site (keys %seenby) {
142 print MAIL "X-KeyServer-Sent: $site\n";
144 print MAIL "X-KeyServer-Sent: $config{thissite}\n";
145 print MAIL "Precedence: list\n";
146 print MAIL "MIME-Version: 1.0\n";
147 print MAIL "Content-Type: application/pgp-keys\n";