1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-06-22 21:07:56 +02:00

gpg: Print the revocation reasons as comment in the pub record.

* g10/keylist.c (list_keyblock_colon): Print the revocation reasons in
the pub record's comment field.
--

GnuPG-bug-id: 7083
This commit is contained in:
Werner Koch 2025-06-20 15:52:54 +02:00
parent 3f825b044b
commit ce5e903bec
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 26 additions and 3 deletions

View File

@ -296,9 +296,12 @@ described here.
*** Field 21 - Comment *** Field 21 - Comment
This is currently only used in "rev" and "rvs" records to carry This is currently only used in "rev", "rvs", ans "pub" records to
the the comment field of the revocation reason. The value is carry the comment field of the revocation reason. The value is
quoted in C style. quoted in C style. For a "pub" record the comment is preceeded by
a human readable recovation reason followed by a LF; this allows
to show the import entire key revocation (class 0x20) reason
without running a --with-sigs listing.
** Special fields ** Special fields

View File

@ -2078,6 +2078,26 @@ list_keyblock_colon (ctrl_t ctrl, kbnode_t keyblock,
es_write_sanitized (es_stdout, pk->updateurl, strlen (pk->updateurl), es_write_sanitized (es_stdout, pk->updateurl, strlen (pk->updateurl),
":", NULL); ":", NULL);
es_putc (':', es_stdout); /* End of field 20 (origin). */ es_putc (':', es_stdout); /* End of field 20 (origin). */
if (pk->flags.revoked && pk->revoked.got_reason
&& (pk->revoked.reason_code || pk->revoked.reason_comment))
{
char *freeme;
const char *s;
size_t n;
s = revocation_reason_code_to_str (pk->revoked.reason_code, &freeme);
n = strlen (s);
es_write_sanitized (es_stdout, s, n, ":", NULL);
if (n && s[n-1] != '.')
es_putc ('.', es_stdout);
es_putc ('\\', es_stdout); /* C-style escaped colon. */
es_putc ('n', es_stdout);
es_write_sanitized (es_stdout, pk->revoked.reason_comment,
pk->revoked.reason_comment_len,
":", NULL);
xfree (freeme);
es_putc (':', es_stdout); /* End of field 21 (comment). */
}
es_putc ('\n', es_stdout); es_putc ('\n', es_stdout);
print_revokers (es_stdout, 1, pk); print_revokers (es_stdout, 1, pk);