[PATCH] --batch should imply --pinentry-mode=loopback???
NIIBE Yutaka
gniibe at fsij.org
Fri May 1 09:30:36 CEST 2015
Hello,
These are fix candidates for the issue 1928:
https://bugs.gnupg.org/gnupg/issue1928
In g10/passphrase.c, there is a condtion like:
(opt.batch || opt.pinentry_mode == PINENTRY_MODE_LOOPBACK)
... which makes me wonder if there is a case people want to specify
options with --batch --pinentry-mode=ask/cancel.
If not, the fix will be (1). If yes, the fix will be (2).
(1) Simple one (passphrase.c will need to fix, later)
=======================================================================
diff --git a/g10/gpg.c b/g10/gpg.c
index 13d6884..4f35bbf 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -2376,6 +2376,7 @@ main (int argc, char **argv)
case oBatch:
opt.batch = 1;
+ opt.pinentry_mode = PINENTRY_MODE_LOOPBACK;
nogreeting = 1;
break;
(2) We pass on pinentry-mode=loopback to gpg-agent when
have_static_passphrase()==1
=======================================================================
diff --git a/g10/call-agent.c b/g10/call-agent.c
index 017e916..5162530 100644
--- a/g10/call-agent.c
+++ b/g10/call-agent.c
@@ -164,17 +164,18 @@ default_inq_cb (void *opaque, const char *line)
log_error (_("failed to proxy %s inquiry to client\n"),
"PINENTRY_LAUNCHED");
/* We do not pass errors to avoid breaking other code. */
+ return err;
}
- else if ((has_leading_keyword (line, "PASSPHRASE")
- || has_leading_keyword (line, "NEW_PASSPHRASE"))
- && opt.pinentry_mode == PINENTRY_MODE_LOOPBACK)
+
+ if ((has_leading_keyword (line, "PASSPHRASE")
+ || has_leading_keyword (line, "NEW_PASSPHRASE")))
{
if (have_static_passphrase ())
{
const char *s = get_static_passphrase ();
- err = assuan_send_data (parm->ctx, s, strlen (s));
+ return assuan_send_data (parm->ctx, s, strlen (s));
}
- else
+ else if (opt.batch || opt.pinentry_mode == PINENTRY_MODE_LOOPBACK)
{
char *pw;
@@ -189,11 +190,11 @@ default_inq_cb (void *opaque, const char *line)
else
err = assuan_send_data (parm->ctx, pw, strlen (pw));
xfree (pw);
+ return err;
}
}
- else
- log_debug ("ignoring gpg-agent inquiry '%s'\n", line);
+ log_debug ("ignoring gpg-agent inquiry '%s'\n", line);
return err;
}
@@ -306,9 +307,10 @@ start_agent (ctrl_t ctrl, int for_card)
assuan_transact (agent_ctx, "OPTION agent-awareness=2.1.0",
NULL, NULL, NULL, NULL, NULL, NULL);
/* Pass on the pinentry mode. */
- if (opt.pinentry_mode)
+ if (have_static_passphrase () || opt.pinentry_mode)
{
char *tmp = xasprintf ("OPTION pinentry-mode=%s",
+ opt.batch ? "loopback" :
str_pinentry_mode (opt.pinentry_mode));
rc = assuan_transact (agent_ctx, tmp,
NULL, NULL, NULL, NULL, NULL, NULL);
--
More information about the Gnupg-devel
mailing list