X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=caff%2Fpgp-fixkey;h=48d47be19e717b581ea0c41822fb527eed90cd78;hb=HEAD;hp=d17723b7b8e6932d53644bcc70d6bda37ca6e044;hpb=cdc1342ce5ec15f3ee28d72b827eb923dcbda8c2;p=pgp-tools.git diff --git a/caff/pgp-fixkey b/caff/pgp-fixkey index d17723b..48d47be 100755 --- a/caff/pgp-fixkey +++ b/caff/pgp-fixkey @@ -262,10 +262,12 @@ if (scalar @KEYIDS == 0) { if ($type eq 'pub') { $thiskey = $keyid; debug("Found key $thiskey"); + } elsif (!defined $thiskey) { + next; } elsif ($type eq 'sig' || $type eq 'rev') { - if (($keyid eq '0' x 16) && ($created == 0)) { - push @KEYIDS, $thiskey if defined $thiskey; - info("Adding $thiskey"); + if (($keyid eq '0' x 16) || ($created eq "") || ($created == 0)) { + push @KEYIDS, $thiskey; + info("Key $thiskey needs cleaning."); $thiskey = undef; }; }; @@ -289,6 +291,10 @@ for my $keyid (@KEYIDS) { }; my $keyinfo = $stdout; my @publine = grep { /^pub/ } (split /\n/, $stdout); + if ($#publine < 0) { + warn ("No public key found for $keyid.\n"); + next; + } my (undef, undef, undef, undef, $longkeyid, undef, undef, undef, undef, undef, undef, $flags) = split /:/, pop @publine; my $can_encrypt = $flags =~ /E/; unless (defined $longkeyid) { @@ -353,8 +359,8 @@ for my $keyid (@KEYIDS) { if (defined $line) { # only if we found a sig here - we never remove revocation packets for instance debug("[sigremoval] doing line $line."); my (undef, undef, undef, undef, $signer, $created, undef, undef, undef) = split /:/, $line; - if ($signer eq ('0' x 16)) { - debug("[sigremoval] not interested in that sig ($signer)."); + if (($signer eq '0' x 16) || ($created == 0)) { + debug("[sigremoval] not interested in that sig ($signer, created: $created)."); $answer = "yes"; }; } else {