summaryrefslogtreecommitdiffstats
path: root/sm
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2018-03-27 08:48:00 +0200
committerWerner Koch <wk@gnupg.org>2018-03-27 08:48:00 +0200
commitd4dc4245bf0221d2db4118718fc2528ecf43b97b (patch)
tree5912abc9b9ba056a882bcd933105ba4dde73c560 /sm
parentChange license of argparse.c back to LGPLv2.1 (diff)
parentagent: Make the request origin a part of the cache items. (diff)
downloadgnupg2-d4dc4245bf0221d2db4118718fc2528ecf43b97b.tar.xz
gnupg2-d4dc4245bf0221d2db4118718fc2528ecf43b97b.zip
Merge branch 'STABLE-BRANCH-2-2' into master
Diffstat (limited to 'sm')
-rw-r--r--sm/call-agent.c14
-rw-r--r--sm/gpgsm.c8
-rw-r--r--sm/gpgsm.h1
-rw-r--r--sm/server.c12
4 files changed, 35 insertions, 0 deletions
diff --git a/sm/call-agent.c b/sm/call-agent.c
index 772c9c312..20d879fa4 100644
--- a/sm/call-agent.c
+++ b/sm/call-agent.c
@@ -179,6 +179,20 @@ start_agent (ctrl_t ctrl)
gpg_strerror (rc));
}
+ /* Pass on the request origin. */
+ if (opt.request_origin)
+ {
+ char *tmp = xasprintf ("OPTION pretend-request-origin=%s",
+ str_request_origin (opt.request_origin));
+ rc = assuan_transact (agent_ctx, tmp,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ xfree (tmp);
+ if (rc)
+ log_error ("setting request origin '%s' failed: %s\n",
+ str_request_origin (opt.request_origin),
+ gpg_strerror (rc));
+ }
+
/* In DE_VS mode under Windows we require that the JENT RNG
* is active. */
#ifdef HAVE_W32_SYSTEM
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index 982be58ba..beabb3854 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -125,6 +125,7 @@ enum cmd_and_opt_values {
oPassphraseFD,
oPinentryMode,
+ oRequestOrigin,
oAssumeArmor,
oAssumeBase64,
@@ -255,6 +256,7 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_s_i (oPassphraseFD, "passphrase-fd", "@"),
ARGPARSE_s_s (oPinentryMode, "pinentry-mode", "@"),
+ ARGPARSE_s_s (oRequestOrigin, "request-origin", "@"),
ARGPARSE_s_n (oAssumeArmor, "assume-armor",
N_("assume input is in PEM format")),
@@ -1162,6 +1164,12 @@ main ( int argc, char **argv)
log_error (_("invalid pinentry mode '%s'\n"), pargs.r.ret_str);
break;
+ case oRequestOrigin:
+ opt.request_origin = parse_request_origin (pargs.r.ret_str);
+ if (opt.request_origin == -1)
+ log_error (_("invalid request origin '%s'\n"), pargs.r.ret_str);
+ break;
+
/* Input encoding selection. */
case oAssumeArmor:
ctrl.autodetect_encoding = 0;
diff --git a/sm/gpgsm.h b/sm/gpgsm.h
index 3e2f95fb3..d3fbde515 100644
--- a/sm/gpgsm.h
+++ b/sm/gpgsm.h
@@ -88,6 +88,7 @@ struct
int with_key_screening; /* Option --with-key-screening active. */
int pinentry_mode;
+ int request_origin;
int armor; /* force base64 armoring (see also ctrl.with_base64) */
int no_armor; /* don't try to figure out whether data is base64 armored*/
diff --git a/sm/server.c b/sm/server.c
index 721f3faf0..98505e26d 100644
--- a/sm/server.c
+++ b/sm/server.c
@@ -32,6 +32,7 @@
#include "../common/sysutils.h"
#include "../common/server-help.h"
#include "../common/asshelp.h"
+#include "../common/shareddefs.h"
#define set_error(e,t) assuan_set_error (ctx, gpg_error (e), (t))
@@ -289,6 +290,17 @@ option_handler (assuan_context_t ctx, const char *key, const char *value)
ctrl->offline = i;
}
}
+ else if (!strcmp (key, "request-origin"))
+ {
+ if (!opt.request_origin)
+ {
+ int i = parse_request_origin (value);
+ if (i == -1)
+ err = gpg_error (GPG_ERR_INV_VALUE);
+ else
+ opt.request_origin = i;
+ }
+ }
else
err = gpg_error (GPG_ERR_UNKNOWN_OPTION);