mutt stable branch with some hacks

Add fingerprint record parsing for pgp list keys. (see #3695)

Modify parse_pub_line to parse fpr records and add the fingerprint to
the pgp_key_t's fingerprint field.

Add "--with-fingerprint --with-fingerprint" to the
pgp_list_pubring_command and pgp_list_secring_command commands in
contrib/gpg.rc. The second invocation generates fpr records for subkeys
too.

+18 -4
+2 -2
contrib/gpg.rc
··· 65 65 set pgp_verify_key_command="gpg --verbose --batch --fingerprint --check-sigs %r" 66 66 67 67 # read in the public key ring 68 - set pgp_list_pubring_command="gpg --no-verbose --batch --quiet --with-colons --list-keys %r" 68 + set pgp_list_pubring_command="gpg --no-verbose --batch --quiet --with-colons --with-fingerprint --with-fingerprint --list-keys %r" 69 69 70 70 # read in the secret key ring 71 - set pgp_list_secring_command="gpg --no-verbose --batch --quiet --with-colons --list-secret-keys %r" 71 + set pgp_list_secring_command="gpg --no-verbose --batch --quiet --with-colons --with-fingerprint --with-fingerprint --list-secret-keys %r" 72 72 73 73 # fetch keys 74 74 # set pgp_getkeys_command="pkspxycwrap %r"
+16 -2
gnupgparse.c
··· 121 121 pgp_uid_t *uid = NULL; 122 122 int field = 0, is_uid = 0; 123 123 int is_pub = 0; 124 + int is_fpr = 0; 124 125 char *pend, *p; 125 126 int trust = 0; 126 127 int flags = 0; ··· 148 149 if (!*p && (field != 1) && (field != 10)) 149 150 continue; 150 151 152 + if (is_fpr && (field != 10)) 153 + continue; 154 + 151 155 switch (field) 152 156 { 153 157 case 1: /* record type */ ··· 164 168 *is_subkey = 1; 165 169 else if (!mutt_strcmp (p, "uid")) 166 170 is_uid = 1; 171 + else if (!mutt_strcmp (p, "fpr")) 172 + is_fpr = 1; 167 173 else 168 174 return NULL; 169 175 170 - if (!(is_uid || (*is_subkey && option (OPTPGPIGNORESUB)))) 176 + if (!(is_uid || is_fpr || (*is_subkey && option (OPTPGPIGNORESUB)))) 171 177 memset (&tmp, 0, sizeof (tmp)); 172 178 173 179 break; ··· 290 296 if (!(pend && (*p || is_pub))) 291 297 break; 292 298 299 + if (is_fpr) 300 + { 301 + /* don't let a subkey fpr overwrite an existing primary key fpr */ 302 + if (!tmp.fingerprint) 303 + tmp.fingerprint = safe_strdup (p); 304 + break; 305 + } 306 + 293 307 /* ignore user IDs on subkeys */ 294 308 if (!is_uid && (*is_subkey && option (OPTPGPIGNORESUB))) 295 309 break; ··· 349 363 } 350 364 351 365 /* merge temp key back into real key */ 352 - if (!(is_uid || (*is_subkey && option (OPTPGPIGNORESUB)))) 366 + if (!(is_uid || is_fpr || (*is_subkey && option (OPTPGPIGNORESUB)))) 353 367 k = safe_malloc (sizeof (*k)); 354 368 memcpy (k, &tmp, sizeof (*k)); 355 369 /* fixup parentship of uids after mering the temp key into