X-Git-Url: http://git.sthu.org/?a=blobdiff_plain;f=gpgsigs%2Fgpgsigs;h=7da3c1f1606f156c43a92241cd8bd9f79f8e05ef;hb=4b2d0f37c3699d65dd84ed590b61d1c038e722e1;hp=a93676dc48d6b1edfa5f068094d36174ee90c892;hpb=e59a6d46869fb001735bc83b2dbb4953a00322bd;p=pgp-tools.git diff --git a/gpgsigs/gpgsigs b/gpgsigs/gpgsigs old mode 100644 new mode 100755 index a93676d..7da3c1f --- a/gpgsigs/gpgsigs +++ b/gpgsigs/gpgsigs @@ -1,5 +1,7 @@ #!/usr/bin/perl +# $Id$ + # See the pod documentation at the end of this file for author, # copyright, and licence information. # @@ -16,7 +18,7 @@ # * better charset conversion # * pod documentation -my $VERSION = "0.2"; +my $VERSION = qq$Rev$; use strict; use warnings; @@ -25,20 +27,24 @@ use IPC::Open3; use Getopt::Long; -sub version +sub version($) { - print STDERR < - (c) 2004 Peter Palfrader + (c) 2004, 2005 Peter Palfrader (c) 2004, 2005 Christoph Berg EOF } -sub usage +sub usage($$) { - version(); - print STDERR <] [] @@ -48,18 +54,19 @@ separate multiple keyids with ',' -f convert from charset -t convert UIDs to charset in output EOF - exit shift; + exit $error; } my ($fromcharset, $charset, $recv_keys); +Getopt::Long::config('bundling'); GetOptions( - f => \$fromcharset, - t => \$charset, + '-f=s' => \$fromcharset, + '-t=s' => \$charset, r => \$recv_keys, - help => sub { usage(0); }, - version => sub { version(); exit 0;}, -) or usage(1); + help => sub { usage(*STDOUT, 0); }, + version => sub { version(*STDOUT); exit 0;}, +) or usage(*STDERR, 1); # charset conversion @@ -127,18 +134,18 @@ sub myrecode($) { # parse options my $mykey = uc(shift @ARGV); -my $keytxt = (shift @ARGV) || usage(1); +my $keytxt = (shift @ARGV) || usage(*STDERR, 1); my $outfile = (shift @ARGV) || '-'; my @mykeys = split /,/, $mykey; map { s/^0x//i; } @mykeys; if (!@mykeys || scalar @ARGV) { - usage(1); + usage(*STDERR, 1); } -if (!grep { /^([0-9A-F]{16,16}|[0-9A-F]{8,8})$/ } @mykeys) { - print STDERR "Invalid keyid given\n"; - usage(1); +foreach my $falsekey (grep { $_ !~ /^([0-9A-F]{16,16}|[0-9A-F]{8,8})$/ } @mykeys) { + print STDERR "Invalid keyid $falsekey given\n"; + usage(*STDERR, 1); } -r $keytxt or die ("$keytxt does not exist\n"); @@ -176,9 +183,21 @@ while () { $uid = myrecode($1); next; } - if ( m/^sig:(?:.*?:){3,3}([0-9A-F]{8})([0-9A-F]{8}):(?:.*?:){3,3}(.*):.*?:/ ) { - $sigs->{$key}->{$uid}->{$1.$2} = $3; - $sigs->{$key}->{$uid}->{$2} = $3; + if ( m/^sig:(?:.*?:){3,3}([0-9A-F]{8})([0-9A-F]{8}):(?:.*?:){5,5}(.*?):/ ) { + my $class = $3; + if ($class eq '10x') { + $class = 'S'; + } elsif ($class eq '11x') { + $class = '1'; + } elsif ($class eq '12x') { + $class = '2'; + } elsif ($class eq '13x') { + $class = '3'; + } else { + $class = 's'; + }; + $sigs->{$key}->{$uid}->{$1.$2} = $class; + $sigs->{$key}->{$uid}->{$2} = $class; next; } if ( m/^uat:/ ) { @@ -219,11 +238,11 @@ sub print_tag my ($key, $uid) = @_; if (! defined $sigs->{$key}->{$uid}) { warn "uid '$uid' not found on key $key\n"; - return '(_)'; + return '(' . (' ' x @mykeys) . ')'; } my $r = '('; foreach my $mykey (@mykeys) { - $r .= defined $sigs->{$key}->{$uid}->{$mykey} ? "S" : " "; + $r .= defined $sigs->{$key}->{$uid}->{$mykey} ? $sigs->{$key}->{$uid}->{$mykey} : ' '; } $r .= ')'; return $r; @@ -235,10 +254,10 @@ open (WRITE, '>'.$outfile) or die ("Cannot open $outfile for writing\n"); while () { $_ = myfromrecode($_); if (/^MD5 Checksum:/ && defined $MD5) { - s/_[_ ]+_/$MD5/; + s/[_[:xdigit:]][_ [:xdigit:]]+_/$MD5/; } if (/^SHA1 Checksum:/ && defined $SHA1) { - s/_[_ ]+_/$SHA1/; + s/[_[:xdigit:]][_ [:xdigit:]]+_/$SHA1/; } if ( m/^pub +(?:\d+)[DR]\/([0-9A-F]{8}) [0-9]{4}-[0-9]{2}-[0-9]{2} *(.*)/ ) { $key = $1; @@ -273,7 +292,7 @@ B - annotate list of GnuPG keys with already done signatures =head1 SYNOPSIS -B [-r] [-f I] [-t I] I F [F] +B [-r] [-f I] [-t I] II<[>B<,>IB<,>I<...>I<]>>I<]> F [F] =head1 DESCRIPTION @@ -303,7 +322,7 @@ LANG, and if all these are unset, the default is ISO-8859-1. =item I Use this keyid (8 or 16 byte) for annotation. Multiple keyids can be separated -by I<,>. +by a comma (B<,>). =item F @@ -338,7 +357,7 @@ http://pgp-tools.alioth.debian.org/ (c) 2004 Uli Martens -(c) 2004 Peter Palfrader +(c) 2004, 2005 Peter Palfrader (c) 2004, 2005 Christoph Berg