1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

Set both the app and default SCD pin prompt at the same time.

Fixes the case when scdaemon prompts for card insertion.

* scd/app-openpgp.c (do_set_pin_prompt): Fix indentation. No longer
unset the prompt with '-' since the OPTION command without a value
does this anyway.
* scd/app.c (expand_pin_prompt): Fix indentation.
* scd/command.c (set_pinentry_prompt): Set both the default and
application prompt when available.
This commit is contained in:
Ben Kibbey 2012-01-23 20:27:14 -05:00
parent 633ea8531e
commit b5aa197a5f
3 changed files with 30 additions and 32 deletions

View File

@ -3765,14 +3765,14 @@ do_set_pin_prompt(app_t app, int which, const char *prompt)
switch (which)
{
case PIN_SIGN_PROMPT:
p = &app->app_local->pin_prompt;
case PIN_SIGN_PROMPT:
p = &app->app_local->pin_prompt;
break;
case PIN_ADMIN_PROMPT:
p = &app->app_local->pin_admin_prompt;
break;
default:
break;
case PIN_ADMIN_PROMPT:
p = &app->app_local->pin_admin_prompt;
break;
default:
break;
}
if (p)
@ -3780,7 +3780,7 @@ do_set_pin_prompt(app_t app, int which, const char *prompt)
xfree (*p);
*p = NULL;
if (prompt && *prompt != '-' && *(prompt+1) != 0)
if (prompt && *prompt)
{
*p = xtrystrdup (prompt);
if (!*p)

View File

@ -969,20 +969,20 @@ expand_pin_prompt(const char *prompt, const char *prepend, int which, ...)
switch (which)
{
/* Signature count. */
case PIN_SIGN_PROMPT:
luval = va_arg (ap, unsigned long);
snprintf (valuebuf, sizeof (valuebuf), "%lu", luval);
token = "|S|";
break;
/* Pin tries remaining. */
case PIN_ADMIN_PROMPT:
intval = va_arg (ap, int);
snprintf (valuebuf, sizeof (valuebuf), "%i", intval);
token = "|A|";
break;
default:
break;
/* Signature count. */
case PIN_SIGN_PROMPT:
luval = va_arg (ap, unsigned long);
snprintf (valuebuf, sizeof (valuebuf), "%lu", luval);
token = "|S|";
break;
/* Pin tries remaining. */
case PIN_ADMIN_PROMPT:
intval = va_arg (ap, int);
snprintf (valuebuf, sizeof (valuebuf), "%i", intval);
token = "|A|";
break;
default:
break;
}
va_end (ap);

View File

@ -395,9 +395,10 @@ reset_notify (assuan_context_t ctx, char *line)
}
static gpg_error_t
set_pinentry_prompt(struct server_local_s *srv, int which, const char *prompt)
set_pinentry_prompt(ctrl_t ctrl, int which, const char *prompt)
{
gpg_error_t rc = 0;
struct server_local_s *srv = ctrl->server_local;
char **p = NULL;
switch (which)
@ -417,7 +418,7 @@ set_pinentry_prompt(struct server_local_s *srv, int which, const char *prompt)
xfree (*p);
*p = NULL;
if (prompt && *prompt != '-' && *(prompt+1) != 0)
if (prompt && *prompt)
{
*p = xtrystrdup (prompt);
if (!*p)
@ -425,6 +426,9 @@ set_pinentry_prompt(struct server_local_s *srv, int which, const char *prompt)
}
}
if (!rc && ctrl->app_ctx)
rc = app_set_pin_prompt (ctrl->app_ctx, PIN_SIGN_PROMPT, prompt);
return rc;
}
@ -451,17 +455,11 @@ option_handler (assuan_context_t ctx, const char *key, const char *value)
* app.c:expand_pin_prompt() for details. */
else if (!strcmp (key, "pin-prompt"))
{
if (ctrl->app_ctx)
return app_set_pin_prompt (ctrl->app_ctx, PIN_SIGN_PROMPT, value);
else
return set_pinentry_prompt (ctrl->server_local, PIN_SIGN_PROMPT, value);
return set_pinentry_prompt (ctrl, PIN_SIGN_PROMPT, value);
}
else if (!strcmp (key, "pin-admin-prompt"))
{
if (ctrl->app_ctx)
return app_set_pin_prompt (ctrl->app_ctx, PIN_ADMIN_PROMPT, value);
else
return set_pinentry_prompt (ctrl->server_local, PIN_ADMIN_PROMPT, value);
return set_pinentry_prompt (ctrl, PIN_ADMIN_PROMPT, value);
}
return 0;