mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
gpg: New command --show-keys.
* g10/gpg.c (aShowKeys): New const. (opts): New command --show-keys. (main): Implement command. * g10/import.c (import_keys_internal): Don't print stats in show-only mode. (import_one): Be silent in show-only mode. -- Using --import --import-options show-only to look at a key is too cumbersome. Provide this shortcut and also remove some diagnostic cruft in this case. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
d2e6b3ea1d
commit
257661d6ae
11
doc/gpg.texi
11
doc/gpg.texi
@ -353,6 +353,14 @@ may thus be used to see what keys @command{@gpgname} might use. In
|
|||||||
particular external methods as defined by @option{--auto-key-locate} may
|
particular external methods as defined by @option{--auto-key-locate} may
|
||||||
be used to locate a key. Only public keys are listed.
|
be used to locate a key. Only public keys are listed.
|
||||||
|
|
||||||
|
@item --show-keys
|
||||||
|
@opindex show-keys
|
||||||
|
This commands takes OpenPGP keys as input and prints information about
|
||||||
|
them in the same way the command @option{--list-keys} does for
|
||||||
|
imported key. No internal state is changed. For automated processing
|
||||||
|
this command should be combined with the option
|
||||||
|
@option{--with-colons}.
|
||||||
|
|
||||||
@item --fingerprint
|
@item --fingerprint
|
||||||
@opindex fingerprint
|
@opindex fingerprint
|
||||||
List all keys (or the specified ones) along with their
|
List all keys (or the specified ones) along with their
|
||||||
@ -2305,7 +2313,8 @@ opposite meaning. The options are:
|
|||||||
Show a listing of the key as imported right before it is stored.
|
Show a listing of the key as imported right before it is stored.
|
||||||
This can be combined with the option @option{--dry-run} to only look
|
This can be combined with the option @option{--dry-run} to only look
|
||||||
at keys; the option @option{show-only} is a shortcut for this
|
at keys; the option @option{show-only} is a shortcut for this
|
||||||
combination. Note that suffixes like '#' for "sec" and "sbb" lines
|
combination. The command @option{--show-keys} is another shortcut
|
||||||
|
for this. Note that suffixes like '#' for "sec" and "sbb" lines
|
||||||
may or may not be printed.
|
may or may not be printed.
|
||||||
|
|
||||||
@item import-export
|
@item import-export
|
||||||
|
11
g10/gpg.c
11
g10/gpg.c
@ -150,6 +150,7 @@ enum cmd_and_opt_values
|
|||||||
aSearchKeys,
|
aSearchKeys,
|
||||||
aRefreshKeys,
|
aRefreshKeys,
|
||||||
aFetchKeys,
|
aFetchKeys,
|
||||||
|
aShowKeys,
|
||||||
aExport,
|
aExport,
|
||||||
aExportSecret,
|
aExportSecret,
|
||||||
aExportSecretSub,
|
aExportSecretSub,
|
||||||
@ -500,6 +501,7 @@ static ARGPARSE_OPTS opts[] = {
|
|||||||
N_("update all keys from a keyserver")),
|
N_("update all keys from a keyserver")),
|
||||||
ARGPARSE_c (aLocateKeys, "locate-keys", "@"),
|
ARGPARSE_c (aLocateKeys, "locate-keys", "@"),
|
||||||
ARGPARSE_c (aFetchKeys, "fetch-keys" , "@" ),
|
ARGPARSE_c (aFetchKeys, "fetch-keys" , "@" ),
|
||||||
|
ARGPARSE_c (aShowKeys, "show-keys" , "@" ),
|
||||||
ARGPARSE_c (aExportSecret, "export-secret-keys" , "@" ),
|
ARGPARSE_c (aExportSecret, "export-secret-keys" , "@" ),
|
||||||
ARGPARSE_c (aExportSecretSub, "export-secret-subkeys" , "@" ),
|
ARGPARSE_c (aExportSecretSub, "export-secret-subkeys" , "@" ),
|
||||||
ARGPARSE_c (aExportSshKey, "export-ssh-key", "@" ),
|
ARGPARSE_c (aExportSshKey, "export-ssh-key", "@" ),
|
||||||
@ -740,6 +742,7 @@ static ARGPARSE_OPTS opts[] = {
|
|||||||
ARGPARSE_c (aListKeys, "list-key", "@"), /* alias */
|
ARGPARSE_c (aListKeys, "list-key", "@"), /* alias */
|
||||||
ARGPARSE_c (aListSigs, "list-sig", "@"), /* alias */
|
ARGPARSE_c (aListSigs, "list-sig", "@"), /* alias */
|
||||||
ARGPARSE_c (aCheckKeys, "check-sig", "@"), /* alias */
|
ARGPARSE_c (aCheckKeys, "check-sig", "@"), /* alias */
|
||||||
|
ARGPARSE_c (aShowKeys, "show-key", "@"), /* alias */
|
||||||
ARGPARSE_s_n (oSkipVerify, "skip-verify", "@"),
|
ARGPARSE_s_n (oSkipVerify, "skip-verify", "@"),
|
||||||
ARGPARSE_s_n (oSkipHiddenRecipients, "skip-hidden-recipients", "@"),
|
ARGPARSE_s_n (oSkipHiddenRecipients, "skip-hidden-recipients", "@"),
|
||||||
ARGPARSE_s_n (oNoSkipHiddenRecipients, "no-skip-hidden-recipients", "@"),
|
ARGPARSE_s_n (oNoSkipHiddenRecipients, "no-skip-hidden-recipients", "@"),
|
||||||
@ -2642,6 +2645,13 @@ main (int argc, char **argv)
|
|||||||
greeting=1;
|
greeting=1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case aShowKeys:
|
||||||
|
set_cmd (&cmd, pargs.r_opt);
|
||||||
|
opt.import_options |= IMPORT_SHOW;
|
||||||
|
opt.import_options |= IMPORT_DRY_RUN;
|
||||||
|
opt.import_options &= ~IMPORT_REPAIR_KEYS;
|
||||||
|
break;
|
||||||
|
|
||||||
case aDetachedSign: detached_sig = 1; set_cmd( &cmd, aSign ); break;
|
case aDetachedSign: detached_sig = 1; set_cmd( &cmd, aSign ); break;
|
||||||
|
|
||||||
case aDecryptFiles: multifile=1; /* fall through */
|
case aDecryptFiles: multifile=1; /* fall through */
|
||||||
@ -4638,6 +4648,7 @@ main (int argc, char **argv)
|
|||||||
case aFastImport:
|
case aFastImport:
|
||||||
opt.import_options |= IMPORT_FAST; /* fall through */
|
opt.import_options |= IMPORT_FAST; /* fall through */
|
||||||
case aImport:
|
case aImport:
|
||||||
|
case aShowKeys:
|
||||||
import_keys (ctrl, argc? argv:NULL, argc, NULL,
|
import_keys (ctrl, argc? argv:NULL, argc, NULL,
|
||||||
opt.import_options, opt.key_origin, opt.key_origin_url);
|
opt.import_options, opt.key_origin, opt.key_origin_url);
|
||||||
break;
|
break;
|
||||||
|
@ -494,7 +494,9 @@ import_keys_internal (ctrl_t ctrl, iobuf_t inp, char **fnames, int nnames,
|
|||||||
|
|
||||||
if (!stats_handle)
|
if (!stats_handle)
|
||||||
{
|
{
|
||||||
import_print_stats (stats);
|
if ((options & (IMPORT_SHOW | IMPORT_DRY_RUN))
|
||||||
|
!= (IMPORT_SHOW | IMPORT_DRY_RUN))
|
||||||
|
import_print_stats (stats);
|
||||||
import_release_stats_handle (stats);
|
import_release_stats_handle (stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1653,6 +1655,10 @@ import_one (ctrl_t ctrl,
|
|||||||
int any_filter = 0;
|
int any_filter = 0;
|
||||||
KEYDB_HANDLE hd = NULL;
|
KEYDB_HANDLE hd = NULL;
|
||||||
|
|
||||||
|
/* If show-only is active we don't won't any extra output. */
|
||||||
|
if ((options & (IMPORT_SHOW | IMPORT_DRY_RUN)))
|
||||||
|
silent = 1;
|
||||||
|
|
||||||
/* Get the key and print some info about it. */
|
/* Get the key and print some info about it. */
|
||||||
node = find_kbnode( keyblock, PKT_PUBLIC_KEY );
|
node = find_kbnode( keyblock, PKT_PUBLIC_KEY );
|
||||||
if (!node )
|
if (!node )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user