3 # gpg2keys_mailto - talk to a email keyserver
4 # Copyright (C) 2001, 2002 Free Software Foundation, Inc.
6 # This file is part of GnuPG.
8 # GnuPG is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # GnuPG is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, see <http://www.gnu.org/licenses/>.
21 $Getopt::Std::STANDARD_HELP_VERSION=1;
22 $sendmail="@SENDMAIL@ -t";
26 sub VERSION_MESSAGE ()
28 print STDOUT "gpg2keys_mailto (GnuPG) @VERSION@\n";
35 --help Print this help
36 --version Print the version
37 -o FILE Write output to FILE
47 open(STDOUT,">$opt_o") || die "Can't open output file $opt_o\n";
52 open(STDIN,$ARGV[0]) || die "Can't open input file $ARGV[0]\n";
80 elsif($1=~/^no-verbose$/i)
84 elsif($1=~/^mail-from=(.+)$/i)
88 elsif($1=~/^no-mail-from$/i)
98 ($login,$name)=(getpwuid($<))[0,6];
99 $from="$name <$login>";
102 $program="(unknown)" if(!defined($program));
104 if(!defined($address))
106 print STDERR "gpgkeys: no address provided\n";
122 print "OPTION OUTOFBAND\n\n";
124 # Email keyservers get and search the same way
126 if($command=~/get/i || $command=~/search/i)
128 if($command=~/search/i)
135 open(MAIL,"|$sendmail") || die "ERROR: Can't open $sendmail\n";
136 print MAIL "From: $from\n";
137 print MAIL "To: $address\n";
140 # mail keyservers don't like long-form keyids
142 if(substr($key,0,2) eq "0x")
149 $key=substr($key,-8);
152 print MAIL "Subject: GET 0x$key\n\n";
156 print MAIL "Subject: GET $key\n\n";
158 print MAIL "GnuPG $program email keyserver request\n";
161 # Tell GnuPG not to expect a key
162 print "KEY $key OUTOFBAND\n";
166 print STDERR "gpgkeys: key $key requested from $address\n";
171 if($command=~/send/i)
175 open(MAIL,"|$sendmail") || die "ERROR: Can't open $sendmail\n";
176 print MAIL "From: $name <$login>\n";
177 print MAIL "To: $address\n";
178 print MAIL "Subject: ADD\n\n";
182 if(/^KEY (\S+) BEGIN$/)
203 print STDERR "gpgkeys: key $key sent to $address\n";