[Pgp-tools-commit] r804 - trunk/caff

Guilhem Moulin guilhem-guest at moszumanska.debian.org
Mon Apr 20 08:33:08 UTC 2015


Author: guilhem-guest
Date: 2015-04-20 08:33:07 +0000 (Mon, 20 Apr 2015)
New Revision: 804

Modified:
   trunk/caff/caff
Log:
caff: lookup the GnuPG version before generating the caffrc.

Modified: trunk/caff/caff
===================================================================
--- trunk/caff/caff	2015-04-14 20:55:47 UTC (rev 803)
+++ trunk/caff/caff	2015-04-20 08:33:07 UTC (rev 804)
@@ -493,6 +493,14 @@
 }
 
 
+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;
+}
+
 open NULL, '+<', '/dev/null';
 my $NULL = fileno NULL;
 sub generate_config() {
@@ -510,11 +518,13 @@
         $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 ]);
         my %output = readwrite_gpg($handles);
-        done_gpg($pid, $handles);
+        waitpid $pid, 0;
+        $handles->{stdout}->close;
 
         if ($output{stdout} eq '') {
             mywarn "No data from gpg for list-key"; # There should be at least 'tru:' everywhere.
@@ -1342,11 +1352,7 @@
 };
 
 
-$GNUPG_VERSION = `$CONFIG{'gpg'} --with-colons --list-config version` or exit 1;
-chomp $GNUPG_VERSION;
-$GNUPG_VERSION =~ s/^cfg:version:(\d+\.\d+).*/$1/;
-debug "gpg (GnuPG) $GNUPG_VERSION";
-
+$GNUPG_VERSION = get_GnuPG_version();
 if ($GNUPG_VERSION >= 2.1) {
     my @sockets;
     unless ($CONFIG{'no-sign'}) {




More information about the Pgp-tools-commit mailing list