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

Guilhem Moulin guilhem-guest at moszumanska.debian.org
Tue Jul 12 19:34:41 UTC 2016


Author: guilhem-guest
Date: 2016-07-12 19:34:41 +0000 (Tue, 12 Jul 2016)
New Revision: 869

Modified:
   trunk/caff/caff
Log:
caff: allow specifying 'local-user' with a key format different from 'keyid'.

Modified: trunk/caff/caff
===================================================================
--- trunk/caff/caff	2016-07-12 19:34:37 UTC (rev 868)
+++ trunk/caff/caff	2016-07-12 19:34:41 UTC (rev 869)
@@ -694,7 +694,7 @@
         mkdir $_, 0700 or myerror(1, "Cannot mkdir $_: $!");
     }
 
-    @{$CONFIG{'keyid'}} = map { s/^0x//; uc (substr y/ //dr, -16) } @{$CONFIG{'keyid'}};
+    @{$CONFIG{'keyid'}} = map { s/^0x//; uc (substr y/ //dr, -16) } @{$CONFIG{'keyid'}}; # must be a list of long keyids
     $CONFIG{'export-sig-age'} //= 24*60*60;
     $CONFIG{'gpg'} //= $ENV{GNUPGBIN} // 'gpg';
 
@@ -1224,14 +1224,11 @@
 
         $user_key =~ s/^0x//;
         $user_key =~ y/ //d;
-        $user_key = uc $user_key;
-
-        unless (grep {$user_key =~ /$_$/} @{$CONFIG{'keyid'}}) {
+        if (my @matching_keyids = grep {$user_key =~ /\Q$_\E$/i or /\Q$user_key\E$/i} @{$CONFIG{'keyid'}}) {
+            push @local_user, @matching_keyids; # @{$CONFIG{'keyid'}} is always a list of long keyids
+        } else {
             mywarn "Local-user $user_key is not defined as one of your keyid in ~/.caffrc (it will not be used)";
-            next;
         }
-
-        push @local_user, $user_key;
     }
 
     # If no local-user key are valid, there is no need to go further
@@ -1606,14 +1603,13 @@
 # import own keys and keys to sign
 ##################################
 import_keys_from_gnupghome($CONFIG{'keyid'}, undef, $GNUPGHOME, 1);
-import_keys_to_sign(\@KEYIDS);
+ at LOCAL_USER = get_local_user_keys() unless $CONFIG{'no-sign'};
 
+import_keys_to_sign(\@KEYIDS);
 if ($CONFIG{'ask-sign'} && ! $CONFIG{'no-sign'}) {
     $CONFIG{'no-sign'} = ! ask("Continue with signing?", 1);
 }
 
- at LOCAL_USER = get_local_user_keys() unless $CONFIG{'no-sign'};
-
 my %KEYS;
 for my $keyid (@KEYIDS) {
     # get key listing (and ensure there is no collision)




More information about the Pgp-tools-commit mailing list