mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
agent: New option --pinentry-formatted-passphrase
* agent/agent.h (opt): Add field pinentry_formatted_passphrase. * agent/call-pinentry.c (setup_formatted_passphrase): New. (agent_get_passphrase): Pass option to pinentry. * agent/gpg-agent.c (oPinentryFormattedPassphrase): New. (opts): Add option. (parse_rereadable_options): Set option. -- GnuPG-bug-id: 5553, 5517 This is a squashed backport of two commits from master. Backport-from-master: bf20a80f68449cc83b67c53ba9a0a84c45827ac4 Backport-from-master: 99601778f4a9dc1c9fee792361c959f5e0732cfd Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
8fff61de94
commit
32fbdddf8b
@ -99,6 +99,9 @@ struct
|
|||||||
upon this timeout value. */
|
upon this timeout value. */
|
||||||
unsigned long pinentry_timeout;
|
unsigned long pinentry_timeout;
|
||||||
|
|
||||||
|
/* If set, then passphrase formatting is enabled in pinentry. */
|
||||||
|
int pinentry_formatted_passphrase;
|
||||||
|
|
||||||
/* The default and maximum TTL of cache entries. */
|
/* The default and maximum TTL of cache entries. */
|
||||||
unsigned long def_cache_ttl; /* Default. */
|
unsigned long def_cache_ttl; /* Default. */
|
||||||
unsigned long def_cache_ttl_ssh; /* for SSH. */
|
unsigned long def_cache_ttl_ssh; /* for SSH. */
|
||||||
|
@ -854,6 +854,56 @@ inq_quality (void *opaque, const char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Helper to setup pinentry for formatted passphrase. */
|
||||||
|
static gpg_error_t
|
||||||
|
setup_formatted_passphrase (ctrl_t ctrl)
|
||||||
|
{
|
||||||
|
static const struct { const char *key, *help_id, *value; } tbl[] = {
|
||||||
|
/* TRANSLATORS: This is a text shown by pinentry if the option
|
||||||
|
for formatted passphrase is enabled. The length is
|
||||||
|
limited to about 900 characters. */
|
||||||
|
{ "hint", "pinentry.formatted_passphrase.hint",
|
||||||
|
N_("Note: The blanks are not part of the passphrase.") },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
gpg_error_t rc;
|
||||||
|
char line[ASSUAN_LINELENGTH];
|
||||||
|
int idx;
|
||||||
|
char *tmpstr;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
(void)ctrl;
|
||||||
|
|
||||||
|
if (opt.pinentry_formatted_passphrase)
|
||||||
|
{
|
||||||
|
snprintf (line, DIM(line), "OPTION formatted-passphrase");
|
||||||
|
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
if (rc && gpg_err_code (rc) != GPG_ERR_UNKNOWN_OPTION)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
for (idx=0; tbl[idx].key; idx++)
|
||||||
|
{
|
||||||
|
tmpstr = gnupg_get_help_string (tbl[idx].help_id, 0);
|
||||||
|
if (tmpstr)
|
||||||
|
s = tmpstr;
|
||||||
|
else
|
||||||
|
s = L_(tbl[idx].value);
|
||||||
|
snprintf (line, DIM(line), "OPTION formatted-passphrase-%s=%s",
|
||||||
|
tbl[idx].key, s);
|
||||||
|
xfree (tmpstr);
|
||||||
|
rc = assuan_transact (entry_ctx, line, NULL, NULL, NULL, NULL, NULL,
|
||||||
|
NULL);
|
||||||
|
if (rc && gpg_err_code (rc) != GPG_ERR_UNKNOWN_OPTION)
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Helper for agent_askpin and agent_get_passphrase. */
|
/* Helper for agent_askpin and agent_get_passphrase. */
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
setup_qualitybar (ctrl_t ctrl)
|
setup_qualitybar (ctrl_t ctrl)
|
||||||
@ -1334,6 +1384,10 @@ agent_get_passphrase (ctrl_t ctrl,
|
|||||||
return unlock_pinentry (ctrl, rc);
|
return unlock_pinentry (ctrl, rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = setup_formatted_passphrase (ctrl);
|
||||||
|
if (rc)
|
||||||
|
return unlock_pinentry (ctrl, rc);
|
||||||
|
|
||||||
if (!pininfo)
|
if (!pininfo)
|
||||||
{
|
{
|
||||||
/* Legacy method without PININFO. */
|
/* Legacy method without PININFO. */
|
||||||
|
@ -98,6 +98,7 @@ enum cmd_and_opt_values
|
|||||||
oPinentryTouchFile,
|
oPinentryTouchFile,
|
||||||
oPinentryInvisibleChar,
|
oPinentryInvisibleChar,
|
||||||
oPinentryTimeout,
|
oPinentryTimeout,
|
||||||
|
oPinentryFormattedPassphrase,
|
||||||
oDisplay,
|
oDisplay,
|
||||||
oTTYname,
|
oTTYname,
|
||||||
oTTYtype,
|
oTTYtype,
|
||||||
@ -191,6 +192,8 @@ static ARGPARSE_OPTS opts[] = {
|
|||||||
ARGPARSE_s_s (oPinentryTouchFile, "pinentry-touch-file", "@"),
|
ARGPARSE_s_s (oPinentryTouchFile, "pinentry-touch-file", "@"),
|
||||||
ARGPARSE_s_s (oPinentryInvisibleChar, "pinentry-invisible-char", "@"),
|
ARGPARSE_s_s (oPinentryInvisibleChar, "pinentry-invisible-char", "@"),
|
||||||
ARGPARSE_s_u (oPinentryTimeout, "pinentry-timeout", "@"),
|
ARGPARSE_s_u (oPinentryTimeout, "pinentry-timeout", "@"),
|
||||||
|
ARGPARSE_s_n (oPinentryFormattedPassphrase, "pinentry-formatted-passphrase",
|
||||||
|
"@"),
|
||||||
ARGPARSE_s_s (oScdaemonProgram, "scdaemon-program",
|
ARGPARSE_s_s (oScdaemonProgram, "scdaemon-program",
|
||||||
/* */ N_("|PGM|use PGM as the SCdaemon program") ),
|
/* */ N_("|PGM|use PGM as the SCdaemon program") ),
|
||||||
ARGPARSE_s_n (oDisableScdaemon, "disable-scdaemon",
|
ARGPARSE_s_n (oDisableScdaemon, "disable-scdaemon",
|
||||||
@ -829,6 +832,7 @@ parse_rereadable_options (ARGPARSE_ARGS *pargs, int reread)
|
|||||||
xfree (opt.pinentry_invisible_char);
|
xfree (opt.pinentry_invisible_char);
|
||||||
opt.pinentry_invisible_char = NULL;
|
opt.pinentry_invisible_char = NULL;
|
||||||
opt.pinentry_timeout = 0;
|
opt.pinentry_timeout = 0;
|
||||||
|
opt.pinentry_formatted_passphrase = 0;
|
||||||
opt.scdaemon_program = NULL;
|
opt.scdaemon_program = NULL;
|
||||||
opt.def_cache_ttl = DEFAULT_CACHE_TTL;
|
opt.def_cache_ttl = DEFAULT_CACHE_TTL;
|
||||||
opt.def_cache_ttl_ssh = DEFAULT_CACHE_TTL_SSH;
|
opt.def_cache_ttl_ssh = DEFAULT_CACHE_TTL_SSH;
|
||||||
@ -889,6 +893,9 @@ parse_rereadable_options (ARGPARSE_ARGS *pargs, int reread)
|
|||||||
opt.pinentry_invisible_char = xtrystrdup (pargs->r.ret_str); break;
|
opt.pinentry_invisible_char = xtrystrdup (pargs->r.ret_str); break;
|
||||||
break;
|
break;
|
||||||
case oPinentryTimeout: opt.pinentry_timeout = pargs->r.ret_ulong; break;
|
case oPinentryTimeout: opt.pinentry_timeout = pargs->r.ret_ulong; break;
|
||||||
|
case oPinentryFormattedPassphrase:
|
||||||
|
opt.pinentry_formatted_passphrase = 1;
|
||||||
|
break;
|
||||||
case oScdaemonProgram: opt.scdaemon_program = pargs->r.ret_str; break;
|
case oScdaemonProgram: opt.scdaemon_program = pargs->r.ret_str; break;
|
||||||
case oDisableScdaemon: opt.disable_scdaemon = 1; break;
|
case oDisableScdaemon: opt.disable_scdaemon = 1; break;
|
||||||
case oDisableCheckOwnSocket: disable_check_own_socket = 1; break;
|
case oDisableCheckOwnSocket: disable_check_own_socket = 1; break;
|
||||||
|
@ -484,6 +484,15 @@ user input. The default value of 0 does not ask the pinentry to
|
|||||||
timeout, however a Pinentry may use its own default timeout value in
|
timeout, however a Pinentry may use its own default timeout value in
|
||||||
this case. A Pinentry may or may not honor this request.
|
this case. A Pinentry may or may not honor this request.
|
||||||
|
|
||||||
|
@item --pinentry-formatted-passphrase
|
||||||
|
@opindex pinentry-formatted-passphrase
|
||||||
|
This option asks the Pinentry to enable passphrase formatting when asking the
|
||||||
|
user for a new passphrase and masking of the passphrase is turned off.
|
||||||
|
|
||||||
|
If passphrase formatting is enabled, then all non-breaking space characters
|
||||||
|
are stripped from the entered passphrase. Passphrase formatting is mostly
|
||||||
|
useful in combination with passphrases generated with the GENPIN command.
|
||||||
|
|
||||||
@item --pinentry-program @var{filename}
|
@item --pinentry-program @var{filename}
|
||||||
@opindex pinentry-program
|
@opindex pinentry-program
|
||||||
Use program @var{filename} as the PIN entry. The default is
|
Use program @var{filename} as the PIN entry. The default is
|
||||||
|
Loading…
x
Reference in New Issue
Block a user