mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Add "gpgconf --kill dirmngr" and avoid useless launch before a kill.
* common/asshelp.c (start_new_gpg_agent): Add arg autostart. Change all callers to use 1 for it. (start_new_dirmngr): Ditto. * tools/gpg-connect-agent.c: Add option --no-autostart. (main): Default autostart to 1. (start_agent): Implement no-autostart. * tools/gpgconf-comp.c (gpg_agent_runtime_change): Use --no-autostart. (scdaemon_runtime_change): Ditto. (dirmngr_runtime_change): New. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
734afee733
commit
0e7dd40342
9 changed files with 88 additions and 35 deletions
|
@ -344,9 +344,10 @@ unlock_spawning (lock_spawn_t *lock, const char *name)
|
|||
}
|
||||
}
|
||||
|
||||
/* Try to connect to the agent via socket or fork it off and work by
|
||||
pipes. Handle the server's initial greeting. Returns a new assuan
|
||||
context at R_CTX or an error code. */
|
||||
/* Try to connect to the agent via socket or start it if it is not
|
||||
running and AUTOSTART is set. Handle the server's initial
|
||||
greeting. Returns a new assuan context at R_CTX or an error
|
||||
code. */
|
||||
gpg_error_t
|
||||
start_new_gpg_agent (assuan_context_t *r_ctx,
|
||||
gpg_err_source_t errsource,
|
||||
|
@ -355,7 +356,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
|
|||
const char *opt_lc_ctype,
|
||||
const char *opt_lc_messages,
|
||||
session_env_t session_env,
|
||||
int verbose, int debug,
|
||||
int autostart, int verbose, int debug,
|
||||
gpg_error_t (*status_cb)(ctrl_t, int, ...),
|
||||
ctrl_t status_cb_arg)
|
||||
{
|
||||
|
@ -376,7 +377,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
|
|||
|
||||
sockname = make_absfilename (homedir, GPG_AGENT_SOCK_NAME, NULL);
|
||||
err = assuan_socket_connect (ctx, sockname, 0, 0);
|
||||
if (err)
|
||||
if (err && autostart)
|
||||
{
|
||||
char *abs_homedir;
|
||||
lock_spawn_t lock;
|
||||
|
@ -491,7 +492,8 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
|
|||
xfree (sockname);
|
||||
if (err)
|
||||
{
|
||||
log_error ("can't connect to the agent: %s\n", gpg_strerror (err));
|
||||
if (autostart || gpg_err_code (err) != GPG_ERR_ASS_CONNECT_FAILED)
|
||||
log_error ("can't connect to the agent: %s\n", gpg_strerror (err));
|
||||
assuan_release (ctx);
|
||||
return gpg_err_make (errsource, GPG_ERR_NO_AGENT);
|
||||
}
|
||||
|
@ -517,13 +519,14 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
|
|||
|
||||
|
||||
/* Try to connect to the dirmngr via a socket. On platforms
|
||||
supporting it, start it up if needed. Returns a new assuan context
|
||||
at R_CTX or an error code. */
|
||||
supporting it, start it up if needed and if AUTOSTART is true.
|
||||
Returns a new assuan context at R_CTX or an error code. */
|
||||
gpg_error_t
|
||||
start_new_dirmngr (assuan_context_t *r_ctx,
|
||||
gpg_err_source_t errsource,
|
||||
const char *homedir,
|
||||
const char *dirmngr_program,
|
||||
int autostart,
|
||||
int verbose, int debug,
|
||||
gpg_error_t (*status_cb)(ctrl_t, int, ...),
|
||||
ctrl_t status_cb_arg)
|
||||
|
@ -557,7 +560,7 @@ start_new_dirmngr (assuan_context_t *r_ctx,
|
|||
err = assuan_socket_connect (ctx, sockname, 0, 0);
|
||||
|
||||
#ifdef USE_DIRMNGR_AUTO_START
|
||||
if (err)
|
||||
if (err && autostart)
|
||||
{
|
||||
lock_spawn_t lock;
|
||||
const char *argv[4];
|
||||
|
@ -670,8 +673,9 @@ start_new_dirmngr (assuan_context_t *r_ctx,
|
|||
|
||||
if (err)
|
||||
{
|
||||
log_error ("connecting dirmngr at '%s' failed: %s\n",
|
||||
sockname, gpg_strerror (err));
|
||||
if (autostart || gpg_err_code (err) != GPG_ERR_ASS_CONNECT_FAILED)
|
||||
log_error ("connecting dirmngr at '%s' failed: %s\n",
|
||||
sockname, gpg_strerror (err));
|
||||
assuan_release (ctx);
|
||||
return gpg_err_make (errsource, GPG_ERR_NO_DIRMNGR);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
|
|||
const char *opt_lc_ctype,
|
||||
const char *opt_lc_messages,
|
||||
session_env_t session_env,
|
||||
int verbose, int debug,
|
||||
int autostart, int verbose, int debug,
|
||||
gpg_error_t (*status_cb)(ctrl_t, int, ...),
|
||||
ctrl_t status_cb_arg);
|
||||
|
||||
|
@ -69,7 +69,7 @@ start_new_dirmngr (assuan_context_t *r_ctx,
|
|||
gpg_err_source_t errsource,
|
||||
const char *homedir,
|
||||
const char *dirmngr_program,
|
||||
int verbose, int debug,
|
||||
int autostart, int verbose, int debug,
|
||||
gpg_error_t (*status_cb)(ctrl_t, int, ...),
|
||||
ctrl_t status_cb_arg);
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ start_agent (void)
|
|||
agentargs.lc_ctype,
|
||||
agentargs.lc_messages,
|
||||
agentargs.session_env,
|
||||
agentargs.verbosity, 0, NULL, NULL);
|
||||
1, agentargs.verbosity, 0, NULL, NULL);
|
||||
if (!err)
|
||||
{
|
||||
/* Tell the agent that we support Pinentry notifications. No
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue