From ec97b4672043bbd74590e96a17564ba899658e54 Mon Sep 17 00:00:00 2001 From: kink-guest Date: Sat, 13 Aug 2005 17:29:35 +0000 Subject: [PATCH] * Reintroduce failure on key not found. * Use strict. git-svn-id: svn://svn.debian.org/pgp-tools/trunk@173 b513b33f-fedd-0310-b452-c3deb5f4c849 --- TODO | 2 -- gpg-key2ps/gpg-key2ps | 28 ++++++++++++++++++---------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index b50422d..1252795 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,5 @@ TODO -- Get Simon's new gpg-key2ps script into the repo, and fix it up so it - provides at least the functionality that gpg-key2ps now has. - Integrate documentation of all different parts. diff --git a/gpg-key2ps/gpg-key2ps b/gpg-key2ps/gpg-key2ps index 4186ba0..e1b1515 100755 --- a/gpg-key2ps/gpg-key2ps +++ b/gpg-key2ps/gpg-key2ps @@ -1,21 +1,24 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w # # gpg-key2ps: convert a PGP/GnuPG key into paper slips. # # $Id$ -$version = '$Rev$'; +use strict; +use Getopt::Std; + +my $version = '$Rev$'; $version =~ s/\$Rev:\s*(\d+)\s*\$/$1/; -$usage = "Usage: $0 [-p papersize] [-r revoked-style] keyid-or-name\n"; -$keyids = ""; -$revokestyle="hide"; +my $usage = "Usage: $0 [-p papersize] [-r revoked-style] keyid-or-name\n"; +my $keyids = ""; +my $revokestyle="hide"; if ( $#ARGV < 0 ) { print $usage; exit 1; } -use Getopt::Std; +my %opts; getopt('pr', \%opts); if ( $opts{r} ) { $revokestyle = $opts{'r'}; } if ( $opts{p} ) { $ENV{'PAPERSIZE'} = $opts{'p'}; } @@ -31,6 +34,7 @@ if ( $revokestyle !~ /^(grey|hide|note|show|strike)$/ ) { exit 1; } +my $w; my $h; if ( -x "/usr/bin/paperconf" ) { $w=`paperconf -w`; $h=`paperconf -h`; @@ -42,6 +46,11 @@ if ( -x "/usr/bin/paperconf" ) { $h=842; } +if ( system( "gpg --fingerprint $keyids >/dev/null" ) != 0 ) { + print STDERR "Key not found. Try 'gpg --list-keys'\n"; + exit 1; +} + open(GPG, "gpg --fingerprint --with-colons $keyids |"); print <) { if ( /^(tru|uat):/ ) { next; } if ( /^pub:/ ) { $numlines++; } s/^pub:[^:]*:([^:]*):([0-9]*):.{8,8}(.{8,8}):([^:]*):[^:]*:[^:]*:[^:]*:([^:]*):[^:]*:[^:]*:.*/ ($5) ($4) ($3) $2 ($1) pub/; if ( /^fpr:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:([^:]*):.*/ ) { - $fpr = $1; + my $fpr = $1; # v4 key $fpr =~ s/(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})/$1 $2 $3 $4 $5 $6 $7 $8 $9 $10/; # v3 key @@ -164,8 +173,6 @@ while() { $numlines++; print; } -$numlines -= 1; - close(GPG); print <