X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=keylookup%2Fkeylookup;h=a69f888ec8857a0eea50a2f0e9c3c14abd194b80;hb=fba02ab5cef2bfceaf97ee19d81af866854d54be;hp=bdf508702cbdfe208d9ebcc8096f1a01b1d2a9f4;hpb=4ea6cbf5bb55fdc9df93a3f8a36db04d19ffa8ae;p=pgp-tools.git diff --git a/keylookup/keylookup b/keylookup/keylookup index bdf5087..a69f888 100755 --- a/keylookup/keylookup +++ b/keylookup/keylookup @@ -24,7 +24,7 @@ # svn://svn.debian.org/pgp-tools/trunk/ # http://svn.debian.org/wsvn/pgp-tools/trunk/ -delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV', 'PATH'}; +delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; $|=1; # Always flush buffers @@ -35,11 +35,6 @@ use Getopt::Long; my $version = '3.0 ($Id$)'; -# Where to find GnuPG's options file. -# Full path to the dialog and whiptail executeable. -my $Dialog = '/usr/bin/dialog'; -my $Whiptail = '/usr/bin/whiptail'; - # Strings to use in the dialog|whiptail frontend my $TITLE = 'Import Keys'; my $BACKTITLE = 'KeyLookup $Revision$'; @@ -104,6 +99,7 @@ sub getHits($) { while () { chomp; + if ( $_ eq "" ) { next; } my ($type, undef) = split /:/; if ($type eq 'pub') { my ($type, $keyid, $algo, $bits, $created, undef, $revoked) = split /:/; @@ -214,7 +210,8 @@ sub callDialog { my %unique; my @keys = grep { !$unique{$_}++ } - grep { /^[0-9A-Fa-f]{8}$/ } + # get the keyID; can be 8, 16 or 40 nibbles + grep { /^((([a-zA-Z0-9]{24})?[a-zA-Z0-9]{8})?[a-zA-Z0-9]{8})$/ } map { s/\s//g; $_ } ; wait; @@ -232,14 +229,14 @@ sub selectKeys { $frontend = 'dialog' unless (defined $frontend); if ($frontend eq 'dialog') { - unless (-x $Dialog) { - warn("Dialog ($Dialog) not executeable/installed. Falling back to Whiptail\n"); + unless (`which dialog` && $? == 0) { + warn("Dialog not executeable/installed. Falling back to Whiptail\n"); $frontend = 'whiptail'; } }; if ($frontend eq 'whiptail') { - unless (-x $Whiptail ) { - warn("Whiptail ($Whiptail) not executeable/installed. Falling back to plain\n"); + unless (`which whiptail` && $? == 0 ) { + warn("Whiptail not executeable/installed. Falling back to plain\n"); $frontend = 'plain'; } }; @@ -247,7 +244,7 @@ sub selectKeys { if ( $frontend eq 'dialog' ) { calcDialogSize; my @ARGS = ( - $Dialog, + 'dialog', '--backtitle', $BACKTITLE, '--separate-output', @@ -261,7 +258,7 @@ sub selectKeys { } elsif ( $frontend eq 'whiptail' ) { calcDialogSize; my @ARGS = ( - $Whiptail, + 'whiptail', '--backtitle', $BACKTITLE, '--separate-output', @@ -300,7 +297,7 @@ sub importKeys { push @args, '--recv-keys'; for my $keyid (@$keyids) { # untaint keyids - my ($cleanid) = $keyid =~ /^([a-zA-Z0-9]{8})$/; + my ($cleanid) = $keyid =~ /^((([a-zA-Z0-9]{24})?[a-zA-Z0-9]{8})?[a-zA-Z0-9]{8})$/; warn ("keyid '$keyid' has unexpected format - skipping\n"), next unless defined $cleanid; push @args, $cleanid;