aboutsummaryrefslogtreecommitdiffstats
path: root/agent/command.c
diff options
context:
space:
mode:
authorNeal H. Walfield <[email protected]>2015-06-18 03:10:47 +0000
committerNeal H. Walfield <[email protected]>2015-06-29 13:53:49 +0000
commit2778c6f8f40d73272075ce04c07097f65c94054e (patch)
treed0e3cc2352fbb73368f4ee371207aa1877338d06 /agent/command.c
parentImprove documentation for default-cache-ttl and default-cache-ttl-ssh. (diff)
downloadgnupg-2778c6f8f40d73272075ce04c07097f65c94054e.tar.gz
gnupg-2778c6f8f40d73272075ce04c07097f65c94054e.zip
Show passphrase constraints errors as password prompt errors
* agent/agent.h (check_passphrase_constraints): Add parameter failed_constraint and remove parameter silent. Update callers. * agent/genkey.c (check_passphrase_constraints): Add parameter failed_constraint and remove parameter silent. If FAILED_CONSTRAINT is not NULL and OPT.ENFORCE_PASSPHRASE_CONSTRAINTS is FALSE, save the error text in *FAILED_CONSTRAINT and don't call take_this_one_anyway or take_this_one_anyway2. If FAILED_CONSTRAINT is NULL, act as if SILENT was set. (agent_ask_new_passphrase): Change initial_errtext's type from a const char * to a char *. Pass it to check_passphrase_constraints. If it contains malloc's memory, free it. -- Signed-off-by: Neal H. Walfield <[email protected]> Based on a patch provided by Watson Yuuma Sato <[email protected]> in issue 2018.
Diffstat (limited to '')
-rw-r--r--agent/command.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/agent/command.c b/agent/command.c
index a4932eff6..a69abc52e 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -1,6 +1,7 @@
/* command.c - gpg-agent command handler
* Copyright (C) 2001-2011 Free Software Foundation, Inc.
* Copyright (C) 2001-2013 Werner Koch
+ * Copyright (C) 2015 g10 Code GmbH.
*
* This file is part of GnuPG.
*
@@ -1438,7 +1439,7 @@ cmd_get_passphrase (assuan_context_t ctx, char *line)
char *p;
int opt_data, opt_check, opt_no_ask, opt_qualbar;
int opt_repeat = 0;
- char *repeat_errtext = NULL;
+ char *entry_errtext = NULL;
if (ctrl->restricted)
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
@@ -1522,15 +1523,16 @@ cmd_get_passphrase (assuan_context_t ctx, char *line)
next_try:
rc = agent_get_passphrase (ctrl, &response, desc, prompt,
- repeat_errtext? repeat_errtext:errtext,
+ entry_errtext? entry_errtext:errtext,
opt_qualbar, cacheid, CACHE_MODE_USER);
- xfree (repeat_errtext);
- repeat_errtext = NULL;
+ xfree (entry_errtext);
+ entry_errtext = NULL;
if (!rc)
{
int i;
- if (opt_check && check_passphrase_constraints (ctrl, response, 0))
+ if (opt_check
+ && check_passphrase_constraints (ctrl, response, &entry_errtext))
{
xfree (response);
goto next_try;
@@ -1548,9 +1550,9 @@ cmd_get_passphrase (assuan_context_t ctx, char *line)
{
xfree (response2);
xfree (response);
- repeat_errtext = try_percent_escape
+ entry_errtext = try_percent_escape
(_("does not match - try again"), NULL);
- if (!repeat_errtext)
+ if (!entry_errtext)
{
rc = gpg_error_from_syserror ();
break;