[Pkg-gnupg-commit] [gnupg2] 52/102: gpg: Add option --with-subkey-fingerprint.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Fri Jun 17 00:14:54 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch experimental
in repository gnupg2.
commit 1d1cb86694fb2223de1da0b3bfffb5c62f505847
Author: Werner Koch <wk at gnupg.org>
Date: Mon Jun 6 16:55:03 2016 +0200
gpg: Add option --with-subkey-fingerprint.
* g10/gpg.c (oWithSubkeyFingerprint): New.
(opts): Add --with-subkey-fingerprint[s].
(main): Set that option.
* g10/options.h (struct opt): Add 'with_subkey_fingerprint'.
* g10/keylist.c (list_keyblock_print): Print subkey fingerprint.
(print_fingerprint): Tweak printing to use compact format if
desirable.
Signed-off-by: Werner Koch <wk at gnupg.org>
---
doc/gpg.texi | 11 ++++++++++-
g10/gpg.c | 6 ++++++
g10/keyid.c | 3 +++
g10/keylist.c | 21 +++++++++++++++++----
g10/options.h | 1 +
5 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/doc/gpg.texi b/doc/gpg.texi
index f190581..f092b27 100644
--- a/doc/gpg.texi
+++ b/doc/gpg.texi
@@ -342,7 +342,8 @@ fingerprints. This is the same output as @option{--list-keys} but with
the additional output of a line with the fingerprint. May also be
combined with @option{--list-sigs} or @option{--check-sigs}. If this
command is given twice, the fingerprints of all secondary keys are
-listed too.
+listed too. This command also forces pretty printing of fingerprints
+if the keyid format has been set to "none".
@item --list-packets
@opindex list-packets
@@ -2276,6 +2277,14 @@ allow to convey suitable information for elliptic curves.
Same as the command @option{--fingerprint} but changes only the format
of the output and may be used together with another command.
+ at item --with-subkey-fingerprint
+ at opindex with-subkey-fingerprint
+If a fingerprint is printed for the primary key, this option forces
+printing of the fingerprint for all subkeys. This could also be
+achieved by using the @option{--with-fingerprint} twice but by using
+this option along with keyid-format "none" a compact fingerprint is
+printed.
+
@item --with-icao-spelling
@opindex with-icao-spelling
Print the ICAO spelling of the fingerprint in addition to the hex digits.
diff --git a/g10/gpg.c b/g10/gpg.c
index d0be4ba..5b4fba6 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -182,6 +182,7 @@ enum cmd_and_opt_values
oNoAskCertLevel,
oFingerprint,
oWithFingerprint,
+ oWithSubkeyFingerprint,
oWithICAOSpelling,
oWithKeygrip,
oWithSecret,
@@ -720,6 +721,8 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_s_n (oUtf8Strings, "utf8-strings", "@"),
ARGPARSE_s_n (oNoUtf8Strings, "no-utf8-strings", "@"),
ARGPARSE_s_n (oWithFingerprint, "with-fingerprint", "@"),
+ ARGPARSE_s_n (oWithSubkeyFingerprint, "with-subkey-fingerprint", "@"),
+ ARGPARSE_s_n (oWithSubkeyFingerprint, "with-subkey-fingerprints", "@"),
ARGPARSE_s_n (oWithICAOSpelling, "with-icao-spelling", "@"),
ARGPARSE_s_n (oWithKeygrip, "with-keygrip", "@"),
ARGPARSE_s_n (oWithSecret, "with-secret", "@"),
@@ -2566,6 +2569,9 @@ main (int argc, char **argv)
opt.with_fingerprint = 1;
opt.fingerprint++;
break;
+ case oWithSubkeyFingerprint:
+ opt.with_subkey_fingerprint = 1;
+ break;
case oWithICAOSpelling:
opt.with_icao_spelling = 1;
break;
diff --git a/g10/keyid.c b/g10/keyid.c
index 20efa01..4cdc41d 100644
--- a/g10/keyid.c
+++ b/g10/keyid.c
@@ -384,6 +384,9 @@ keystrlen(void)
switch(format)
{
+ case KF_NONE:
+ return 0;
+
case KF_SHORT:
return 8;
diff --git a/g10/keylist.c b/g10/keylist.c
index abd5ffa..231f3c0 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -1168,7 +1168,7 @@ list_keyblock_print (ctrl_t ctrl, kbnode_t keyblock, int secret, int fpr,
/* Print the "sub" line. */
print_key_line (es_stdout, pk2, secret);
- if (fpr > 1)
+ if (fpr > 1 || opt.with_subkey_fingerprint)
{
print_fingerprint (NULL, pk2, 0);
if (serialno)
@@ -1821,6 +1821,10 @@ print_fingerprint (estream_t override_fp, PKT_public_key *pk, int mode)
compact = 1;
}
+ if (!opt.fingerprint && !opt.with_fingerprint
+ && opt.with_subkey_fingerprint && opt.keyid_format == KF_NONE)
+ compact = 1;
+
if (pk->main_keyid[0] == pk->keyid[0]
&& pk->main_keyid[1] == pk->keyid[1])
primary = 1;
@@ -1873,7 +1877,13 @@ print_fingerprint (estream_t override_fp, PKT_public_key *pk, int mode)
else
{
fp = override_fp? override_fp : es_stdout;
- text = _(" Key fingerprint =");
+ if (opt.keyid_format == KF_NONE)
+ {
+ text = " "; /* To indent ICAO spelling. */
+ compact = 1;
+ }
+ else
+ text = _(" Key fingerprint =");
}
hexfingerprint (pk, hexfpr, sizeof hexfpr);
@@ -1881,7 +1891,7 @@ print_fingerprint (estream_t override_fp, PKT_public_key *pk, int mode)
{
es_fprintf (fp, "fpr:::::::::%s:", hexfpr);
}
- else if (compact)
+ else if (compact && !opt.fingerprint && !opt.with_fingerprint)
{
tty_fprintf (fp, "%*s%s", 6, "", hexfpr);
}
@@ -1889,7 +1899,10 @@ print_fingerprint (estream_t override_fp, PKT_public_key *pk, int mode)
{
char fmtfpr[MAX_FORMATTED_FINGERPRINT_LEN + 1];
format_hexfingerprint (hexfpr, fmtfpr, sizeof fmtfpr);
- tty_fprintf (fp, "%s %s", text, fmtfpr);
+ if (compact)
+ tty_fprintf (fp, "%*s%s", 6, "", fmtfpr);
+ else
+ tty_fprintf (fp, "%s %s", text, fmtfpr);
}
tty_fprintf (fp, "\n");
if (!with_colons && with_icao)
diff --git a/g10/options.h b/g10/options.h
index 55f974a..2ae1724 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -71,6 +71,7 @@ struct
int with_key_data;
int with_icao_spelling; /* Print ICAO spelling with fingerprints. */
int with_fingerprint; /* Option --with-fingerprint active. */
+ int with_subkey_fingerprint; /* Option --with-subkey-fingerprint active. */
int with_keygrip; /* Option --with-keygrip active. */
int with_secret; /* Option --with-secret active. */
int with_wkd_hash; /* Option --with-wkd-hash. */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list