From 45bae004035ab4a06a67def285c55bc82df6c39a Mon Sep 17 00:00:00 2001 From: myon-guest Date: Sun, 26 Jun 2005 23:10:19 +0000 Subject: [PATCH] * use getopt * new options -mMR git-svn-id: svn://svn.debian.org/pgp-tools/trunk@79 b513b33f-fedd-0310-b452-c3deb5f4c849 --- caff/caff | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/caff/caff b/caff/caff index 9fd1633..a911248 100755 --- a/caff/caff +++ b/caff/caff @@ -39,7 +39,7 @@ caff -- CA - Fire and Forget =over -=item B [-u I] I [I ..] +=item B [-mMR] [-u I] I [I ..] =back @@ -55,6 +55,14 @@ sigs and sigs done by you. =over +=item B<-m> B<-M> + +Send/do not send mail after signing. Default is to ask the user for each uid. + +=item B<-R> + +Do not retrieve the key to be signed from a keyserver. + =item B<-u> I Select the key that is used for signing, in case you have more than one key. @@ -162,6 +170,7 @@ use File::Temp qw{tempdir}; use MIME::Entity; use Fcntl; use IO::Select; +use Getopt::Std; use GnuPG::Interface; my %CONFIG; @@ -368,7 +377,7 @@ my $DATE_STRING = sprintf("%04d-%02d-%02d", $year+1900, $mon+1, $mday); sub usage() { print STDERR "caff $VERSION - (c) 2004, 2005 Peter Palfrader\n"; - print STDERR "Usage: $PROGRAM_NAME [-u ] [ ...]\n"; + print STDERR "Usage: $PROGRAM_NAME [-mMR] [-u ] [ ...]\n"; exit 1; }; @@ -485,12 +494,13 @@ sub sanitize_uid($) { my $USER; my @KEYIDS; +my %opt; + +getopts('mMRu:', \%opt); usage() unless scalar @ARGV >= 1; -if ($ARGV[0] eq '-u') { - usage() unless scalar @ARGV >= 3; - shift @ARGV; - $USER = shift @ARGV; +if ($opt{u}) { + $USER = $opt{u}; $USER =~ s/^0x//i; unless ($USER =~ /^[A-Za-z0-9]{8,8}([A-Za-z0-9]{8})?$/) { print STDERR "-u $USER is not a keyid.\n"; @@ -539,7 +549,7 @@ for my $keyid (@ARGV) { ############################# my @keyids_ok; my @keyids_failed; -if ($CONFIG{'no-download'}) { +if ($CONFIG{'no-download'} or $opt{R}) { @keyids_ok = @KEYIDS; } else { my $gpg = GnuPG::Interface->new(); @@ -798,7 +808,9 @@ for my $keyid (@keyids_ok) { if (scalar @UIDS == 0) { info("found no signed uids for $keyid"); } else { - my @attached ; + next if $opt{M}; # do not send mail + + my @attached; for my $uid (@UIDS) { trace("UID: $uid->{'text'}\n"); unless ($uid->{'text'} =~ /@/) { @@ -812,8 +824,7 @@ for my $keyid (@keyids_ok) { if ($uid->{'text'} =~ /@/) { my $address = $uid->{'text'}; $address =~ s/.*<(.*)>.*/$1/; - my $send = ask("Send mail to '$address' for $uid->{'text'}?", 1); - if ($send) { + if ($opt{m} or ask("Send mail to '$address' for $uid->{'text'}?", 1)) { my $mail = send_mail($address, $can_encrypt, $longkeyid, $uid, @attached); my $keydir = "$KEYSBASE/$DATE_STRING"; -- 2.39.5