[Pgp-tools-commit] r856 - in trunk: caff debian

Guilhem Moulin guilhem-guest at moszumanska.debian.org
Sun Jul 10 20:01:37 UTC 2016


Author: guilhem-guest
Date: 2016-07-10 20:01:37 +0000 (Sun, 10 Jul 2016)
New Revision: 856

Modified:
   trunk/caff/caff
   trunk/debian/changelog
Log:
caff: fix compatibility with GnuPG 2.1.13.

Modified: trunk/caff/caff
===================================================================
--- trunk/caff/caff	2016-07-10 20:01:33 UTC (rev 855)
+++ trunk/caff/caff	2016-07-10 20:01:37 UTC (rev 856)
@@ -518,6 +518,20 @@
     return 0;
 }
 
+sub gpgconf(@) {
+    my $pid = open my $fh, '-|', 'gpgconf', @_;
+    my %conf;
+    while (<$fh>) {
+        my ($k, $v) = split /:/, $_;
+        chomp ($conf{$k} = $v);
+        $conf{$k} =~ s/%(\p{AHex}{2})/ chr(hex($1)) /ge; # unescape the %-encoded chars
+    }
+    waitpid $pid, 0;
+    myerror($?, "gpgconf exited with value ".($? >> 8)) if $?;
+    close $fh;
+    return \%conf;
+}
+
 # See RFC 5322 section 3.4.1; only the pattern for the local part, which
 # doesn't go beyond the ASCII range, is validated.  The domain part is
 # NOT checked against RFC 5322, as it must be encoded to ASCII first;
@@ -1458,31 +1472,42 @@
 
 
 if (GnuPG_version('2.1.0') >= 0) {
-    my @sockets;
+    my %sockets;
     unless ($CONFIG{'no-sign'}) {
         # Ensure we have a working agent for our secret key material
         my $secdir = $CONFIG{'secret-keyring'};
         $secdir =~ s#/[^/]+$## unless -d $secdir;
         mysystem('gpg-connect-agent', '--homedir', $secdir, '/bye');
-        push @sockets, "$secdir/S.gpg-agent";
+        $sockets{'agent-socket'} = GnuPG_version('2.1.13') < 0 ?
+            # gpgconf < 2.1.13 doesn't understand --homedir; but on
+            # these versions the gpg-agent socket path is always
+            # $GNUPGHOME/S.gpg-agent.
+            "$secdir/S.gpg-agent" :
+            gpgconf('--homedir', $secdir, '--list-dirs')->{'agent-socket'};
     }
     unless ($CONFIG{'no-download'}) {
         # Ensure we have a working agent for the downloads
         my $homedir = $ENV{'GNUPGHOME'} // "$ENV{'HOME'}/.gnupg";
         mysystem('gpg-connect-agent', '--homedir', $homedir, '--dirmngr', '/bye');
-        push @sockets, "$homedir/S.dirmngr";
+        $sockets{'dirmngr-socket'} = GnuPG_version('2.1.13') < 0 ?
+            # gpgconf < 2.1.13 doesn't understand --homedir; but on
+            # these versions the gpg-agent socket path is always
+            # $GNUPGHOME/S.dirmngr.
+            "$homedir/S.dirmngr" :
+            gpgconf('--homedir', $homedir, '--list-dirs')->{'dirmngr-socket'};
     }
 
-    foreach my $socket (@sockets) {
-        my $l = $socket =~ s#.*/(S\.[^/]+)$#$GNUPGHOME/$1#r;
+    foreach my $k (keys %sockets) {
+        my $socket = $sockets{$k};
+        my $l = GnuPG_version('2.1.13') < 0 ?
+            $socket =~ s#.*/#$GNUPGHOME/#r :
+            gpgconf('--homedir', $GNUPGHOME, '--list-dirs')->{$k};
         if (-l $l) {
             unlink $l
-        }
-        elsif (-S $l) {
+        } elsif (-S $l) {
             # don't run agents in caff's homedir
             myerror(1, "$l: socket exists; runaway gpg-agent?");
-        }
-        elsif (! -S $socket) {
+        } elsif (! -S $socket) {
             myerror(1, "Missing socket $socket");
         }
         debug "Creating symlink $l to $socket";

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2016-07-10 20:01:33 UTC (rev 855)
+++ trunk/debian/changelog	2016-07-10 20:01:37 UTC (rev 856)
@@ -5,7 +5,11 @@
   * 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.
+  * caff:
+    + Fix GnuPG version number comparison.
+    + With GnuPG 2.1.13 or later, use gpgconf(1) to determine the socket
+      paths.  (It is not used on earlier gpg since earlier gpgconf do not
+      support --homedir.)  This fixes compatibility with GnuPG 2.1.13.
 
  -- Guilhem Moulin <guilhem at guilhem.org>  Sun, 10 Jul 2016 17:27:39 +0200
 




More information about the Pgp-tools-commit mailing list