aboutsummaryrefslogtreecommitdiffstats
path: root/sm
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2014-11-28 08:44:19 +0000
committerWerner Koch <[email protected]>2014-11-28 08:44:19 +0000
commit7aee3579be6e24a1aa280e75615fc3a11ceef960 (patch)
treef8ae9f5c3cf5b30d7bfa6d31e37417d9c823996b /sm
parentgpg-agent: Add restricted connection feature. (diff)
downloadgnupg-7aee3579be6e24a1aa280e75615fc3a11ceef960.tar.gz
gnupg-7aee3579be6e24a1aa280e75615fc3a11ceef960.zip
Add option --no-autostart.
* g10/gpg.c: Add option --no-autostart. * sm/gpgsm.c: Ditto. * g10/options.h (opt): Add field autostart. * sm/gpgsm.h (opt): Ditto. * g10/call-agent.c (start_agent): Print note if agent was not autostarted. * sm/call-agent.c (start_agent): Ditto. * g10/call-dirmngr.c (create_context): Likewise. * sm/call-dirmngr.c (start_dirmngr_ext): Ditto. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'sm')
-rw-r--r--sm/call-agent.c14
-rw-r--r--sm/call-dirmngr.c12
-rw-r--r--sm/gpgsm.c7
-rw-r--r--sm/gpgsm.h1
4 files changed, 30 insertions, 4 deletions
diff --git a/sm/call-agent.c b/sm/call-agent.c
index 59b1509b6..f579200ff 100644
--- a/sm/call-agent.c
+++ b/sm/call-agent.c
@@ -95,10 +95,20 @@ start_agent (ctrl_t ctrl)
opt.agent_program,
opt.lc_ctype, opt.lc_messages,
opt.session_env,
- 1, opt.verbose, DBG_ASSUAN,
+ opt.autostart, opt.verbose, DBG_ASSUAN,
gpgsm_status2, ctrl);
- if (!rc)
+ if (!opt.autostart && gpg_err_code (rc) == GPG_ERR_NO_AGENT)
+ {
+ static int shown;
+
+ if (!shown)
+ {
+ shown = 1;
+ log_info (_("no gpg-agent running in this session\n"));
+ }
+ }
+ else if (!rc)
{
/* Tell the agent that we support Pinentry notifications. No
error checking so that it will work also with older
diff --git a/sm/call-dirmngr.c b/sm/call-dirmngr.c
index 4dc8425d6..f8cfdf8e8 100644
--- a/sm/call-dirmngr.c
+++ b/sm/call-dirmngr.c
@@ -209,8 +209,18 @@ start_dirmngr_ext (ctrl_t ctrl, assuan_context_t *ctx_r)
err = start_new_dirmngr (&ctx, GPG_ERR_SOURCE_DEFAULT,
opt.homedir, opt.dirmngr_program,
- 1, opt.verbose, DBG_ASSUAN,
+ opt.autostart, opt.verbose, DBG_ASSUAN,
gpgsm_status2, ctrl);
+ if (!opt.autostart && gpg_err_code (err) == GPG_ERR_NO_DIRMNGR)
+ {
+ static int shown;
+
+ if (!shown)
+ {
+ shown = 1;
+ log_info (_("no dirmngr running in this session\n"));
+ }
+ }
prepare_dirmngr (ctrl, ctx, err);
if (err)
return err;
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index 03b9bb9c9..3398d173f 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -183,7 +183,8 @@ enum cmd_and_opt_values {
oIgnoreTimeConflict,
oNoRandomSeedFile,
oNoCommonCertsImport,
- oIgnoreCertExtension
+ oIgnoreCertExtension,
+ oNoAutostart
};
@@ -391,6 +392,7 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_s_n (oNoRandomSeedFile, "no-random-seed-file", "@"),
ARGPARSE_s_n (oNoCommonCertsImport, "no-common-certs-import", "@"),
ARGPARSE_s_s (oIgnoreCertExtension, "ignore-cert-extension", "@"),
+ ARGPARSE_s_n (oNoAutostart, "no-autostart", "@"),
/* Command aliases. */
ARGPARSE_c (aListKeys, "list-key", "@"),
@@ -940,6 +942,7 @@ main ( int argc, char **argv)
dotlock_create (NULL, 0); /* Register lockfile cleanup. */
+ opt.autostart = 1;
opt.session_env = session_env_new ();
if (!opt.session_env)
log_fatal ("error allocating session environment block: %s\n",
@@ -1417,6 +1420,8 @@ main ( int argc, char **argv)
add_to_strlist (&opt.ignored_cert_extensions, pargs.r.ret_str);
break;
+ case oNoAutostart: opt.autostart = 0; break;
+
default:
pargs.err = configfp? ARGPARSE_PRINT_WARNING:ARGPARSE_PRINT_ERROR;
break;
diff --git a/sm/gpgsm.h b/sm/gpgsm.h
index e8322b731..63c9d0b27 100644
--- a/sm/gpgsm.h
+++ b/sm/gpgsm.h
@@ -69,6 +69,7 @@ struct
char *lc_ctype;
char *lc_messages;
+ int autostart;
const char *dirmngr_program;
int disable_dirmngr; /* Do not do any dirmngr calls. */
const char *protect_tool_program;