From b9455d161650fbadb1dcc9cc4284a227b4d1086c Mon Sep 17 00:00:00 2001 From: weasel Date: Sun, 20 Nov 2005 00:47:06 +0000 Subject: [PATCH] This patch checks whether the GPG executables are indeed executable, and dies if they aren't. Thanks to nickm for the patch. git-svn-id: svn://svn.debian.org/pgp-tools/trunk@256 b513b33f-fedd-0310-b452-c3deb5f4c849 --- caff/caff | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/caff/caff b/caff/caff index 6868d41..052ef8b 100755 --- a/caff/caff +++ b/caff/caff @@ -373,6 +373,22 @@ $Ckeys\$CONFIG{'keyid'} = [ qw{@keys} ]; EOT }; +sub check_executable($$) { + # (GnuPG::Interface gives lousy errors when the gpg binary isn't found, + # so we want to check manually.) + my ($purpose, $fn) = @_; + # Only check provided fnames with a slash in them. + return unless defined $fn; + if ($fn =~ m!/!) { + die ("$PROGRAM_NAME: $purpose executable '$fn' not found.\n") unless -x $fn; + } else { + for my $p (split(':', $ENV{PATH})) { + return if -x "$p/$fn"; + }; + die ("$PROGRAM_NAME: $purpose executable '$fn' not found on path.\n") unless -x $fn; + }; +}; + sub load_config() { my $config = $ENV{'HOME'} . '/.caffrc'; unless (-f $config) { @@ -402,6 +418,9 @@ sub load_config() { $CONFIG{'gpg'} = 'gpg' unless defined $CONFIG{'gpg'}; $CONFIG{'gpg-sign'} = $CONFIG{'gpg'} unless defined $CONFIG{'gpg-sign'}; $CONFIG{'gpg-delsig'} = $CONFIG{'gpg'} unless defined $CONFIG{'gpg-delsig'}; + check_executable("gpg", $CONFIG{'gpg'}); + check_executable("gpg-sign", $CONFIG{'gpg-sign'}); + check_executable("gpg-delsig", $CONFIG{'gpg-delsig'}); $CONFIG{'secret-keyring'} = $ENV{'HOME'}.'/.gnupg/secring.gpg' unless defined $CONFIG{'secret-keyring'}; $CONFIG{'no-download'} = 0 unless defined $CONFIG{'no-download'}; $CONFIG{'no-sign'} = 0 unless defined $CONFIG{'no-sign'}; -- 2.39.5