aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/asshelp.c20
-rw-r--r--common/util.h6
2 files changed, 23 insertions, 3 deletions
diff --git a/common/asshelp.c b/common/asshelp.c
index e675fdad8..51ef17227 100644
--- a/common/asshelp.c
+++ b/common/asshelp.c
@@ -504,9 +504,23 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
err = assuan_transact (ctx, "RESET",
NULL, NULL, NULL, NULL, NULL, NULL);
if (!err)
- err = send_pinentry_environment (ctx, errsource,
- opt_lc_ctype, opt_lc_messages,
- session_env);
+ {
+ err = send_pinentry_environment (ctx, errsource,
+ opt_lc_ctype, opt_lc_messages,
+ session_env);
+ if (gpg_err_code (err) == GPG_ERR_FORBIDDEN
+ && gpg_err_source (err) == GPG_ERR_SOURCE_GPGAGENT)
+ {
+ /* Check whether we are in restricted mode. */
+ if (!assuan_transact (ctx, "GETINFO restricted",
+ NULL, NULL, NULL, NULL, NULL, NULL))
+ {
+ if (verbose)
+ log_info (_("connection to agent is in restricted mode\n"));
+ err = 0;
+ }
+ }
+ }
if (err)
{
assuan_release (ctx);
diff --git a/common/util.h b/common/util.h
index dd5fdb14c..a6f86069a 100644
--- a/common/util.h
+++ b/common/util.h
@@ -35,6 +35,12 @@
#include <errno.h> /* We need errno. */
#include <gpg-error.h> /* We need gpg_error_t and estream. */
+/* These error codes are used but not defined in the required
+ libgpg-error version. Define them here. */
+#if GPG_ERROR_VERSION_NUMBER < 0x011200 /* 1.18 */
+# define GPG_ERR_FORBIDDEN 251
+#endif
+
/* Hash function used with libksba. */
#define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write)