gpgsm: New option --no-pretty-dn

* sm/gpgsm.c (oNoPrettyDN): New.
(opts): Add --no-pretty-dn.
(main): Implement.
* sm/gpgsm.h (opt): Add no_pretty_dn.
* sm/certdump.c (gpgsm_es_print_name): Act upon.
This commit is contained in:
Werner Koch 2023-03-16 09:46:05 +01:00
parent e5066f2d1c
commit e4ac3e7dec
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
4 changed files with 25 additions and 2 deletions

View File

@ -629,6 +629,15 @@ always listed in @option{--with-colons} mode.
Include info about the presence of a secret key in public key listings
done with @code{--with-colons}.
@item --no-pretty-dn
@opindex no-pretty-dn
By default gpgsm prints distinguished names (DNs) like the Issuer or
Subject in a more readable format (e.g. using a well defined order of
the parts). However, this format can't be used as input strings.
This option reverts printing to standard RFC-2253 format and thus
avoids the need to use --dump-cert or --with-colons to get the
``real'' name.
@end table
@c *******************************************

View File

@ -728,7 +728,14 @@ gpgsm_es_print_name2 (estream_t fp, const char *name, int translate)
void
gpgsm_es_print_name (estream_t fp, const char *name)
{
gpgsm_es_print_name2 (fp, name, 1);
if (opt.no_pretty_dn)
{
if (!name)
name = "[error]";
es_write_sanitized (fp, name, strlen (name), NULL, NULL);
}
else
gpgsm_es_print_name2 (fp, name, 1);
}

View File

@ -170,6 +170,7 @@ enum cmd_and_opt_values {
oWithKeyScreening,
oAnswerYes,
oAnswerNo,
oNoPrettyDN,
oKeyring,
oDefaultKey,
oDefRecipient,
@ -385,7 +386,7 @@ static gpgrt_opt_t opts[] = {
ARGPARSE_s_n (oWithKeygrip, "with-keygrip", "@"),
ARGPARSE_s_n (oWithSecret, "with-secret", "@"),
ARGPARSE_s_n (oWithKeyScreening,"with-key-screening", "@"),
ARGPARSE_s_n (oNoPrettyDN, "no-pretty-dn", "@"),
ARGPARSE_header ("Security", N_("Options controlling the security")),
@ -1318,6 +1319,10 @@ main ( int argc, char **argv)
opt.with_key_screening = 1;
break;
case oNoPrettyDN:
opt.no_pretty_dn = 1;
break;
case oHomedir: gnupg_set_homedir (pargs.r.ret_str); break;
case oChUid: break; /* Command line only (see above). */
case oAgentProgram: opt.agent_program = pargs.r.ret_str; break;

View File

@ -85,6 +85,8 @@ struct
int with_key_screening; /* Option --with-key-screening active. */
int no_pretty_dn; /* Option --no-pretty-dn */
int pinentry_mode;
int request_origin;