From 7d788514693cfc5c94bf9c4306ff9cc082e96330 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 22 Oct 2014 21:00:59 +0200 Subject: Work with newer GnuPG::Interface versions again Newer GnuPG::Interface versions are more picky when it comes to command and command_args. Previously, they would accept things in any order and would not care which of the two arrays had which. Now, command_args is really limited to have arguments for the command listed in command. Any options go with, and in front of, the command. --- Echolot/Conf.pm | 3 +-- Echolot/Pinger/CPunk.pm | 17 ++++++++--------- Echolot/Stats.pm | 8 ++++---- NEWS | 6 ++++++ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Echolot/Conf.pm b/Echolot/Conf.pm index 3d57543..0ccd117 100644 --- a/Echolot/Conf.pm +++ b/Echolot/Conf.pm @@ -387,8 +387,7 @@ sub parse_cpunk_key($$$) { for my $key (@pgp_keys) { my ( $stdin_fh, $stdout_fh, $stderr_fh, $status_fh, $handles ) = Echolot::Tools::make_gpg_fds(); my $pid = $GnuPG->wrap_call( - commands => [qw{--with-colons}], - command_args => [qw{--no-options --no-secmem-warning --no-default-keyring --fast-list-mode}], + commands => [qw{--with-colons --no-options --no-secmem-warning --no-default-keyring --fast-list-mode}], handles => $handles ); my ($stdout, $stderr, $status) = Echolot::Tools::readwrite_gpg($key, $stdin_fh, $stdout_fh, $stderr_fh, $status_fh); waitpid $pid, 0; diff --git a/Echolot/Pinger/CPunk.pm b/Echolot/Pinger/CPunk.pm index ccd679e..6240e2a 100644 --- a/Echolot/Pinger/CPunk.pm +++ b/Echolot/Pinger/CPunk.pm @@ -59,8 +59,8 @@ sub encrypt_to($$$$) { my ( $stdin_fh, $stdout_fh, $stderr_fh, $status_fh, $handles ) = Echolot::Tools::make_gpg_fds(); my $pid = $GnuPG->wrap_call( - commands => [ '--import' ], - command_args => [qw{--no-options --no-secmem-warning --no-default-keyring --fast-list-mode --keyring}, $keyring, '--', '-' ], + commands => [qw{--no-options --no-secmem-warning --no-default-keyring --fast-list-mode --keyring}, $keyring, '--import'], + command_args => ['--', '-' ], handles => $handles ); my ($stdout, $stderr, $status) = Echolot::Tools::readwrite_gpg($keys->{$recipient}->{'key'}, $stdin_fh, $stdout_fh, $stderr_fh, $status_fh); waitpid $pid, 0; @@ -88,12 +88,8 @@ sub encrypt_to($$$$) { armor => 1 ); ( $stdin_fh, $stdout_fh, $stderr_fh, $status_fh, $handles ) = Echolot::Tools::make_gpg_fds(); - my $command_args = [qw{--no-options --no-secmem-warning --always-trust --no-default-keyring --textmode --cipher-algo 3DES --keyring}, $keyring, '--recipient', $recipient]; my $plaintextfile; - #if ($pgp2compat) { - # push @$command_args, qw{--pgp2}; - #}; # Files are required for compaitibility with PGP 2.* # we also use files in all other cases since there is a bug in either GnuPG or GnuPG::Interface # that let Echolot die if in certain cases: @@ -109,9 +105,12 @@ sub encrypt_to($$$$) { close (F) or Echolot::Log::warn("Cannot close $plaintextfile."), return 0; - push @$command_args, $plaintextfile; - $pid = $GnuPG->encrypt( + my $commands = [qw{--no-options --no-secmem-warning --always-trust --no-default-keyring --textmode --cipher-algo 3DES --keyring}, $keyring, '--recipient', $recipient, '--encrypt']; + my $command_args = ['--', $plaintextfile]; + + $pid = $GnuPG->wrap_call( + commands => $commands, command_args => $command_args, handles => $handles ); ($stdout, $stderr, $status) = Echolot::Tools::readwrite_gpg('', $stdin_fh, $stdout_fh, $stderr_fh, $status_fh); @@ -125,7 +124,7 @@ sub encrypt_to($$$$) { return undef; (($status =~ /^\[GNUPG:\] BEGIN_ENCRYPTION\s/m) && ($status =~ /^\[GNUPG:\] END_ENCRYPTION\s/m)) or - Echolot::Log::info("GnuPG status '$status' didn't indicate message to '$recipient' was encrypted correctly (stderr: $stderr; args: ".join(' ', @$command_args).")."), + Echolot::Log::info("GnuPG status '$status' didn't indicate message to '$recipient' was encrypted correctly (stderr: $stderr; args: ".join(' ', @$commands, @$command_args).")."), return undef; unlink ($keyring) or diff --git a/Echolot/Stats.pm b/Echolot/Stats.pm index 2ee2527..a1f0b75 100644 --- a/Echolot/Stats.pm +++ b/Echolot/Stats.pm @@ -876,8 +876,8 @@ sub build_pgpring_type($$$$) { if ( defined Echolot::Globals::get()->{'storage'}->get_nick($addr) ) { my ( $stdin_fh, $stdout_fh, $stderr_fh, $status_fh, $handles ) = Echolot::Tools::make_gpg_fds(); my $pid = $GnuPG->wrap_call( - commands => [ '--import' ], - command_args => [qw{--no-options --no-secmem-warning --no-default-keyring --fast-list-mode --keyring}, $keyring, '--', '-' ], + commands => [qw{--no-options --no-secmem-warning --no-default-keyring --fast-list-mode --keyring}, $keyring, '--import'], + command_args => ['--', '-'], handles => $handles ); my ($stdout, $stderr, $status) = Echolot::Tools::readwrite_gpg($key{'key'}, $stdin_fh, $stdout_fh, $stderr_fh, $status_fh); waitpid $pid, 0; @@ -904,8 +904,8 @@ sub build_pgpring_export($$$$) { my ( $stdin_fh, $stdout_fh, $stderr_fh, $status_fh, $handles ) = Echolot::Tools::make_gpg_fds(); my $pid = $GnuPG->wrap_call( - commands => [ '--export' ], - command_args => [qw{--no-options --no-secmem-warning --no-default-keyring --keyring}, $keyring, @$keyids ], + commands => [qw{--no-options --no-secmem-warning --no-default-keyring --keyring}, $keyring, '--export'], + command_args => ['--', @$keyids ], handles => $handles ); my ($stdout, $stderr, $status) = Echolot::Tools::readwrite_gpg('', $stdin_fh, $stdout_fh, $stderr_fh, $status_fh); waitpid $pid, 0; diff --git a/NEWS b/NEWS index 033dcfd..8192043 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,12 @@ Changes in * Fix a bashishm in tools/create-distribution. * Fix a markup typo in the pingd manpage. * Fix "defined(@array) is deprecated" in Echolot/Tools.pm + * Newer GnuPG::Interface versions are more picky when it comes + to command and command_args. Previously, they would accept things + in any order and would not care which of the two arrays had which. + Now, command_args is really limited to have arguments for the + command listed in command. Any options go with, and in front of, + the command. Changes in version 2.1.8 - 2005-04-25 * debian: Redirect init script output to /dev/null in logrotate -- cgit v1.2.3