[Pgp-tools-commit] r855 - in trunk: caff debian
Guilhem Moulin
guilhem-guest at moszumanska.debian.org
Sun Jul 10 20:01:33 UTC 2016
Author: guilhem-guest
Date: 2016-07-10 20:01:33 +0000 (Sun, 10 Jul 2016)
New Revision: 855
Modified:
trunk/caff/caff
trunk/debian/changelog
Log:
caff: fix GnuPG version comparison.
Before we had 1.10 < 1.4, and minor version number wasn't supported.
Modified: trunk/caff/caff
===================================================================
--- trunk/caff/caff 2016-07-10 20:01:29 UTC (rev 854)
+++ trunk/caff/caff 2016-07-10 20:01:33 UTC (rev 855)
@@ -443,7 +443,6 @@
my @LOCAL_USER;
my $PARAMS;
-my $GNUPG_VERSION;
my $KEYSBASE;
my $GNUPGHOME;
@@ -499,12 +498,24 @@
}
-sub get_GnuPG_version() {
- my $version = `$CONFIG{gpg} --with-colons --list-config version` or exit 1;
- chomp $version;
- $version =~ s/^cfg:version:(\d+\.\d+).*/$1/;
- debug "gpg (GnuPG) $version";
- return $version;
+# Return -1 if the GnuPG version is < $_[0], 0 if == $_[0], 1 if > $_[0].
+my $GNUPG_VERSION;
+sub GnuPG_version($) {
+ unless (defined $GNUPG_VERSION) { # cache the version
+ $GNUPG_VERSION = `$CONFIG{gpg} --with-colons --list-config version` or exit 1;
+ chomp $GNUPG_VERSION;
+ $GNUPG_VERSION =~ s/^cfg:version:// or die;
+ debug "gpg (GnuPG) $GNUPG_VERSION";
+ }
+ my @v1 = split /\./, $GNUPG_VERSION;
+ my @v2 = split /\./, shift;
+ while (@v1 or @v2) {
+ my $v1 = shift @v1 // 0;
+ my $v2 = shift @v2 // 0;
+ my $r = $v1 <=> $v2;
+ return $r unless $r == 0;
+ }
+ return 0;
}
# See RFC 5322 section 3.4.1; only the pattern for the local part, which
@@ -568,7 +579,6 @@
$gecos =~ s/,.*//;
$CONFIG{'gpg'} = $ENV{GNUPGBIN} // 'gpg';
- $GNUPG_VERSION = get_GnuPG_version();
my $gpg = mkGnuPG( extra_args => ['--with-colons'] );
my $handles = mkGnuPG_fds ( stdout => undef );
my $pid = $gpg->list_public_keys(handles => $handles, command_args => [ $gecos ]);
@@ -772,8 +782,8 @@
$h{extra_args} //= [];
push @{$h{extra_args}}, '--no-auto-check-trustdb';
- push @{$h{extra_args}}, '--fixed-list-mode' if $GNUPG_VERSION < 2.0;
- push @{$h{extra_args}}, '--no-autostart' if $GNUPG_VERSION >= 2.1; # never autostart
+ push @{$h{extra_args}}, '--fixed-list-mode' if GnuPG_version('2.0.0') < 0;
+ push @{$h{extra_args}}, '--no-autostart' if GnuPG_version('2.1.0') >= 0; # never autostart
$gpg->options->hash_init(%h);
debug(join (' ', $gpg->call(), $gpg->options->get_args(), "..."));
@@ -1224,7 +1234,7 @@
my @extra_args;
push @import_options, 'import-local-sigs' if $CONFIG{'gpg-sign-type'} =~ /l/ and !grep /import-local-sigs$/, @import_options;
- push @import_options, 'keep-ownertrust' unless defined $dst_gpghome or $GNUPG_VERSION >= 2.1; # don't modify our own trustdb
+ push @import_options, 'keep-ownertrust' unless defined $dst_gpghome or GnuPG_version('2.1.0') >= 0; # don't modify our own trustdb
push @extra_args, '--min-cert-level=1' if grep { $_ eq 'import-clean' } @import_options;
push @extra_args, '--import-options', join (',', @import_options) if @import_options;
@@ -1447,8 +1457,7 @@
};
-$GNUPG_VERSION = get_GnuPG_version();
-if ($GNUPG_VERSION >= 2.1) {
+if (GnuPG_version('2.1.0') >= 0) {
my @sockets;
unless ($CONFIG{'no-sign'}) {
# Ensure we have a working agent for our secret key material
@@ -1635,7 +1644,7 @@
my @command = ($CONFIG{'gpg'});
push @command, '--local-user', $local_user;
push @command, "--homedir=$GNUPGHOME";
- push @command, '--secret-keyring', $CONFIG{'secret-keyring'} if $GNUPG_VERSION < 2.1;
+ push @command, '--secret-keyring', $CONFIG{'secret-keyring'} if GnuPG_version('2.1.0') < 0;
push @command, qw/--no-auto-check-trustdb --trust-model=always/;
push @command, '--edit-key', $keyid;
push @command, 'showphoto' if $CONFIG{'show-photos'};
@@ -1784,7 +1793,7 @@
foreach my $local_user (@LOCAL_USER) {
my @command = ($CONFIG{'gpg'});
push @command, '--local-user', $local_user;
- push @command, '--secret-keyring', $CONFIG{'secret-keyring'} if $GNUPG_VERSION < 2.1;
+ push @command, '--secret-keyring', $CONFIG{'secret-keyring'} if GnuPG_version('2.1.0') < 0;
push @command, qw/--no-auto-check-trustdb --trust-model=always/;
push @command, '--edit-key', $keyid;
push @command, 'showphoto' if $CONFIG{'show-photos'};
@@ -1812,8 +1821,8 @@
}
my $gpg = mkGnuPG( extra_args => ['--local-user' => $u, '--ask-cert-level', '--with-colons', '--no-batch'] );
- $gpg->options->push_extra_args('--secret-keyring', $CONFIG{'secret-keyring'}) if $GNUPG_VERSION < 2.1;
- $gpg->options->push_extra_args('--use-agent') if $GNUPG_VERSION < 2.0; # we know there is a working agent
+ $gpg->options->push_extra_args('--secret-keyring', $CONFIG{'secret-keyring'}) if GnuPG_version('2.1.0') < 0;
+ $gpg->options->push_extra_args('--use-agent') if GnuPG_version('2.0.0') < 0; # we know there is a working agent
my $handles = mkGnuPG_fds( command => undef, stdout => undef, status => undef );
my $pid = $gpg->wrap_call(
commands => [ '--edit-key' ],
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2016-07-10 20:01:29 UTC (rev 854)
+++ trunk/debian/changelog 2016-07-10 20:01:33 UTC (rev 855)
@@ -5,6 +5,7 @@
* caff, gpgsigs: Allow input produced by gpgparticipants(1) using gpg
2.1.13. With this version, key IDs are not displayed by default and the
"Key fingerprint = " prefix is omitted.
+ * caff: Fix GnuPG version number comparison.
-- Guilhem Moulin <guilhem at guilhem.org> Sun, 10 Jul 2016 17:27:39 +0200
More information about the Pgp-tools-commit
mailing list