diff options
author | Werner Koch <[email protected]> | 2019-08-23 10:50:41 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2019-08-23 10:53:58 +0000 |
commit | 589f1187137cb14da1d16be1fdaf8f1ac2c2d436 (patch) | |
tree | 0d270be415bd5b96be3cdbaeadc3a23512498b81 | |
parent | gpg: Do not show an informational diagnostics with quiet. (diff) | |
download | gnupg-589f1187137cb14da1d16be1fdaf8f1ac2c2d436.tar.gz gnupg-589f1187137cb14da1d16be1fdaf8f1ac2c2d436.zip |
gpg: Silence some warning messages during -Kv.
* g10/options.h (glo_ctrl): Add flag silence_parse_warnings.
* g10/keylist.c (list_all): Set that during secret key listsings.
* g10/parse-packet.c (unknown_pubkey_warning): If new flag is set do
not print info message normally emitted inh verbose mode.
(can_handle_critical_notation, enum_sig_subpkt): Ditto.
(parse_signature, parse_key, parse_attribute_subpkts): Ditto.
--
Those messages are annoying because they might be emitted due to
parsing public keys which are latter not shows because the secret part
is missing. No functional regressions are expected because --verbose
should not change anything.
Note that this suppression is only done if no arguments are given to
the command; that is if a listing of the entire keyring is requested.
Thus to see the earnings anyway, a listing of a single or group of
keys can be requested.
GnuPG-bug-id: 4627
Signed-off-by: Werner Koch <[email protected]>
(cherry picked from commit d7aca1bef68589134b36395901b92496a7a37392)
-rw-r--r-- | g10/keylist.c | 4 | ||||
-rw-r--r-- | g10/options.h | 3 | ||||
-rw-r--r-- | g10/parse-packet.c | 22 |
3 files changed, 19 insertions, 10 deletions
diff --git a/g10/keylist.c b/g10/keylist.c index 62b787557..13f27cb0a 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -523,7 +523,11 @@ list_all (ctrl_t ctrl, int secret, int mark_secret) lastresname = NULL; do { + if (secret) + glo_ctrl.silence_parse_warnings++; rc = keydb_get_keyblock (hd, &keyblock); + if (secret) + glo_ctrl.silence_parse_warnings--; if (rc) { if (gpg_err_code (rc) == GPG_ERR_LEGACY_KEY) diff --git a/g10/options.h b/g10/options.h index 994c1b241..08739afd6 100644 --- a/g10/options.h +++ b/g10/options.h @@ -293,6 +293,9 @@ struct { codes. Thus for the --server purposes we store some of the error codes here. FIXME! */ gpg_error_t lasterr; + + /* Kludge to silence some warnings using --secret-key-list. */ + int silence_parse_warnings; } glo_ctrl; #define DBG_PACKET_VALUE 1 /* debug packet reading/writing */ diff --git a/g10/parse-packet.c b/g10/parse-packet.c index 2d6ec9205..85d8f33b7 100644 --- a/g10/parse-packet.c +++ b/g10/parse-packet.c @@ -267,7 +267,7 @@ unknown_pubkey_warning (int algo) encryption/signing. */ if (pubkey_get_npkey (algo)) { - if (opt.verbose) + if (opt.verbose && !glo_ctrl.silence_parse_warnings) { if (!pubkey_get_nsig (algo)) log_info ("public key algorithm %s not suitable for %s\n", @@ -282,7 +282,7 @@ unknown_pubkey_warning (int algo) algo &= 0xff; if (!unknown_pubkey_algos[algo]) { - if (opt.verbose) + if (opt.verbose && !glo_ctrl.silence_parse_warnings) log_info (_("can't handle public key algorithm %d\n"), algo); unknown_pubkey_algos[algo] = 1; } @@ -1641,7 +1641,7 @@ can_handle_critical_notation (const byte *name, size_t len) if (sl->flags == len && !memcmp (sl->d, name, len)) return 1; /* Known */ - if (opt.verbose) + if (opt.verbose && !glo_ctrl.silence_parse_warnings) { log_info(_("Unknown critical signature notation: ") ); print_utf8_buffer (log_get_stream(), name, len); @@ -1761,7 +1761,7 @@ enum_sig_subpkt (const subpktarea_t * pktbuf, sigsubpkttype_t reqtype, goto too_short; if (!can_handle_critical (buffer + 1, n - 1, type)) { - if (opt.verbose) + if (opt.verbose && !glo_ctrl.silence_parse_warnings) log_info (_("subpacket of type %d has " "critical bit set\n"), type); if (start) @@ -1812,14 +1812,14 @@ enum_sig_subpkt (const subpktarea_t * pktbuf, sigsubpkttype_t reqtype, return NULL; /* End of packets; not found. */ too_short: - if (opt.verbose) + if (opt.verbose && !glo_ctrl.silence_parse_warnings) log_info ("buffer shorter than subpacket\n"); if (start) *start = -1; return NULL; no_type_byte: - if (opt.verbose) + if (opt.verbose && !glo_ctrl.silence_parse_warnings) log_info ("type octet missing in subpacket\n"); if (start) *start = -1; @@ -2029,7 +2029,7 @@ parse_signature (IOBUF inp, int pkttype, unsigned long pktlen, if (p) sig->timestamp = buf32_to_u32 (p); else if (!(sig->pubkey_algo >= 100 && sig->pubkey_algo <= 110) - && opt.verbose) + && opt.verbose && !glo_ctrl.silence_parse_warnings) log_info ("signature packet without timestamp\n"); p = parse_sig_subpkt2 (sig, SIGSUBPKT_ISSUER); @@ -2039,7 +2039,7 @@ parse_signature (IOBUF inp, int pkttype, unsigned long pktlen, sig->keyid[1] = buf32_to_u32 (p + 4); } else if (!(sig->pubkey_algo >= 100 && sig->pubkey_algo <= 110) - && opt.verbose) + && opt.verbose && !glo_ctrl.silence_parse_warnings) log_info ("signature packet without keyid\n"); p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_SIG_EXPIRE, NULL); @@ -2286,7 +2286,9 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen, } else if (version == 2 || version == 3) { - if (opt.verbose > 1) + /* Not anymore supported since 2.1. Use an older gpg version + * (i.e. gpg 1.4) to parse v3 packets. */ + if (opt.verbose > 1 && !glo_ctrl.silence_parse_warnings) log_info ("packet(%d) with obsolete version %d\n", pkttype, version); if (list_mode) es_fprintf (listfp, ":key packet: [obsolete version %d]\n", version); @@ -2760,7 +2762,7 @@ parse_attribute_subpkts (PKT_user_id * uid) return count; too_short: - if (opt.verbose) + if (opt.verbose && !glo_ctrl.silence_parse_warnings) log_info ("buffer shorter than attribute subpacket\n"); uid->attribs = attribs; uid->numattribs = count; |