1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-21 19:48:05 +01:00

gpg: Sync print of additional sig data in --edit-key.

* g10/keylist.c (show_policy_url): Implement MODE -1.
(show_keyserver_url): Ditto.
(show_notation): Ditto.
* g10/keyedit.c (print_one_sig): Print policy URL, keyserver URL and
notation data to the tty.
--

With this change the listing of signatures in the key edit menu does
now include policy URLs et al in order and not possible after leaving
the menu (it used to go to stdout and not the tty).

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2017-01-17 10:23:52 +01:00
parent bae42e5437
commit 766c25018b
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 44 additions and 47 deletions

View File

@ -281,11 +281,11 @@ print_one_sig (int rc, KBNODE keyblock, KBNODE node,
if (sig->flags.policy_url if (sig->flags.policy_url
&& ((opt.list_options & LIST_SHOW_POLICY_URLS) || extended)) && ((opt.list_options & LIST_SHOW_POLICY_URLS) || extended))
show_policy_url (sig, 3, 0); show_policy_url (sig, 3, -1);
if (sig->flags.notation if (sig->flags.notation
&& ((opt.list_options & LIST_SHOW_NOTATIONS) || extended)) && ((opt.list_options & LIST_SHOW_NOTATIONS) || extended))
show_notation (sig, 3, 0, show_notation (sig, 3, -1,
((opt. ((opt.
list_options & LIST_SHOW_STD_NOTATIONS) ? 1 : 0) + list_options & LIST_SHOW_STD_NOTATIONS) ? 1 : 0) +
((opt. ((opt.
@ -293,7 +293,7 @@ print_one_sig (int rc, KBNODE keyblock, KBNODE node,
if (sig->flags.pref_ks if (sig->flags.pref_ks
&& ((opt.list_options & LIST_SHOW_KEYSERVER_URLS) || extended)) && ((opt.list_options & LIST_SHOW_KEYSERVER_URLS) || extended))
show_keyserver_url (sig, 3, 0); show_keyserver_url (sig, 3, -1);
if (extended) if (extended)
{ {

View File

@ -304,6 +304,7 @@ status_one_subpacket (sigsubpkttype_t type, size_t len, int flags,
/* Print a policy URL. Allowed values for MODE are: /* Print a policy URL. Allowed values for MODE are:
* -1 - print to the TTY
* 0 - print to stdout. * 0 - print to stdout.
* 1 - use log_info and emit status messages. * 1 - use log_info and emit status messages.
* 2 - emit only status messages. * 2 - emit only status messages.
@ -314,50 +315,48 @@ show_policy_url (PKT_signature * sig, int indent, int mode)
const byte *p; const byte *p;
size_t len; size_t len;
int seq = 0, crit; int seq = 0, crit;
estream_t fp = mode ? log_get_stream () : es_stdout; estream_t fp = mode < 0? NULL : mode ? log_get_stream () : es_stdout;
while ((p = while ((p =
enum_sig_subpkt (sig->hashed, SIGSUBPKT_POLICY, &len, &seq, &crit))) enum_sig_subpkt (sig->hashed, SIGSUBPKT_POLICY, &len, &seq, &crit)))
{ {
if (mode != 2) if (mode != 2)
{ {
int i;
const char *str; const char *str;
for (i = 0; i < indent; i++) tty_fprintf (fp, "%*s", indent, "");
es_putc (' ', fp);
if (crit) if (crit)
str = _("Critical signature policy: "); str = _("Critical signature policy: ");
else else
str = _("Signature policy: "); str = _("Signature policy: ");
if (mode) if (mode > 0)
log_info ("%s", str); log_info ("%s", str);
else else
es_fprintf (fp, "%s", str); tty_fprintf (fp, "%s", str);
print_utf8_buffer (fp, p, len); tty_print_utf8_string2 (fp, p, len, 0);
es_fprintf (fp, "\n"); tty_fprintf (fp, "\n");
} }
if (mode) if (mode > 0)
write_status_buffer (STATUS_POLICY_URL, p, len, 0); write_status_buffer (STATUS_POLICY_URL, p, len, 0);
} }
} }
/* /* Print a keyserver URL. Allowed values for MODE are:
mode=0 for stdout. * -1 - print to the TTY
mode=1 for log_info + status messages * 0 - print to stdout.
mode=2 for status messages only * 1 - use log_info and emit status messages.
*/ * 2 - emit only status messages.
/* TODO: use this */ */
void void
show_keyserver_url (PKT_signature * sig, int indent, int mode) show_keyserver_url (PKT_signature * sig, int indent, int mode)
{ {
const byte *p; const byte *p;
size_t len; size_t len;
int seq = 0, crit; int seq = 0, crit;
estream_t fp = mode ? log_get_stream () : es_stdout; estream_t fp = mode < 0? NULL : mode ? log_get_stream () : es_stdout;
while ((p = while ((p =
enum_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_KS, &len, &seq, enum_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_KS, &len, &seq,
@ -365,43 +364,43 @@ show_keyserver_url (PKT_signature * sig, int indent, int mode)
{ {
if (mode != 2) if (mode != 2)
{ {
int i;
const char *str; const char *str;
for (i = 0; i < indent; i++) tty_fprintf (fp, "%*s", indent, "");
es_putc (' ', es_stdout);
if (crit) if (crit)
str = _("Critical preferred keyserver: "); str = _("Critical preferred keyserver: ");
else else
str = _("Preferred keyserver: "); str = _("Preferred keyserver: ");
if (mode) if (mode > 0)
log_info ("%s", str); log_info ("%s", str);
else else
es_fprintf (es_stdout, "%s", str); tty_fprintf (es_stdout, "%s", str);
print_utf8_buffer (fp, p, len); tty_print_utf8_string2 (fp, p, len, 0);
es_fprintf (fp, "\n"); tty_fprintf (fp, "\n");
} }
if (mode) if (mode > 0)
status_one_subpacket (SIGSUBPKT_PREF_KS, len, status_one_subpacket (SIGSUBPKT_PREF_KS, len,
(crit ? 0x02 : 0) | 0x01, p); (crit ? 0x02 : 0) | 0x01, p);
} }
} }
/*
mode=0 for stdout.
mode=1 for log_info + status messages
mode=2 for status messages only
Defined bits in WHICH: /* Print notation data. Allowed values for MODE are:
1 == standard notations * -1 - print to the TTY
2 == user notations * 0 - print to stdout.
*/ * 1 - use log_info and emit status messages.
* 2 - emit only status messages.
*
* Defined bits in WHICH:
* 1 - standard notations
* 2 - user notations
*/
void void
show_notation (PKT_signature * sig, int indent, int mode, int which) show_notation (PKT_signature * sig, int indent, int mode, int which)
{ {
estream_t fp = mode ? log_get_stream () : es_stdout; estream_t fp = mode < 0? NULL : mode ? log_get_stream () : es_stdout;
notation_t nd, notations; notation_t nd, notations;
if (which == 0) if (which == 0)
@ -418,34 +417,32 @@ show_notation (PKT_signature * sig, int indent, int mode, int which)
if ((which & 1 && !has_at) || (which & 2 && has_at)) if ((which & 1 && !has_at) || (which & 2 && has_at))
{ {
int i;
const char *str; const char *str;
for (i = 0; i < indent; i++) tty_fprintf (fp, "%*s", indent, "");
es_putc (' ', es_stdout);
if (nd->flags.critical) if (nd->flags.critical)
str = _("Critical signature notation: "); str = _("Critical signature notation: ");
else else
str = _("Signature notation: "); str = _("Signature notation: ");
if (mode) if (mode > 0)
log_info ("%s", str); log_info ("%s", str);
else else
es_fprintf (es_stdout, "%s", str); tty_fprintf (es_stdout, "%s", str);
/* This is all UTF8 */ /* This is all UTF8 */
print_utf8_buffer (fp, nd->name, strlen (nd->name)); tty_print_utf8_string2 (fp, nd->name, strlen (nd->name), 0);
es_fprintf (fp, "="); tty_fprintf (fp, "=");
print_utf8_buffer (fp, nd->value, strlen (nd->value)); tty_print_utf8_string2 (fp, nd->value, strlen (nd->value), 0);
/* (We need to use log_printf so that the next call to a /* (We need to use log_printf so that the next call to a
log function does not insert an extra LF.) */ log function does not insert an extra LF.) */
if (mode) if (mode > 0)
log_printf ("\n"); log_printf ("\n");
else else
es_putc ('\n', fp); tty_fprintf (fp, "\n");
} }
} }
if (mode) if (mode > 0)
{ {
write_status_buffer (STATUS_NOTATION_NAME, write_status_buffer (STATUS_NOTATION_NAME,
nd->name, strlen (nd->name), 0); nd->name, strlen (nd->name), 0);