mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-21 10:09:57 +01:00
common: Prepare for more flags in start_new_service.
* common/asshelp.h (ASSHELP_FLAG_AUTOSTART): New. * common/asshelp.c (start_new_service): Rename arg autostart to flags and adjust checks. (start_new_gpg_agent): Likewise. Change all callers. (start_new_keyboxd): Likewise. Change all callers. (start_new_dirmngr): Likewise. Change all callers. -- It is easier to have a generic flags arg instead of adding more and more dedicated args. verbose and debug are kept as they are because they are not boolean.
This commit is contained in:
parent
716e59b0b6
commit
a430f22549
@ -386,7 +386,8 @@ start_new_service (assuan_context_t *r_ctx,
|
||||
const char *opt_lc_ctype,
|
||||
const char *opt_lc_messages,
|
||||
session_env_t session_env,
|
||||
int autostart, int verbose, int debug,
|
||||
unsigned int flags,
|
||||
int verbose, int debug,
|
||||
gpg_error_t (*status_cb)(ctrl_t, int, ...),
|
||||
ctrl_t status_cb_arg)
|
||||
{
|
||||
@ -445,7 +446,7 @@ start_new_service (assuan_context_t *r_ctx,
|
||||
}
|
||||
|
||||
err = assuan_socket_connect (ctx, sockname, 0, connect_flags);
|
||||
if (err && autostart)
|
||||
if (err && (flags & ASSHELP_FLAG_AUTOSTART))
|
||||
{
|
||||
char *abs_homedir;
|
||||
lock_spawn_t lock;
|
||||
@ -547,7 +548,8 @@ start_new_service (assuan_context_t *r_ctx,
|
||||
xfree (sockname);
|
||||
if (err)
|
||||
{
|
||||
if (autostart || gpg_err_code (err) != GPG_ERR_ASS_CONNECT_FAILED)
|
||||
if ((flags & ASSHELP_FLAG_AUTOSTART)
|
||||
|| gpg_err_code (err) != GPG_ERR_ASS_CONNECT_FAILED)
|
||||
log_error ("can't connect to the %s: %s\n",
|
||||
printed_name, gpg_strerror (err));
|
||||
assuan_release (ctx);
|
||||
@ -599,55 +601,58 @@ 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 autostart, int verbose, int debug,
|
||||
unsigned int flags,
|
||||
int verbose, int debug,
|
||||
gpg_error_t (*status_cb)(ctrl_t, int, ...),
|
||||
ctrl_t status_cb_arg)
|
||||
{
|
||||
return start_new_service (r_ctx, GNUPG_MODULE_NAME_AGENT,
|
||||
errsource, agent_program,
|
||||
opt_lc_ctype, opt_lc_messages, session_env,
|
||||
autostart, verbose, debug,
|
||||
flags, verbose, debug,
|
||||
status_cb, status_cb_arg);
|
||||
}
|
||||
|
||||
|
||||
/* Try to connect to the dirmngr via a socket. On platforms
|
||||
supporting it, start it up if needed and if AUTOSTART is true.
|
||||
supporting it, start it up if needed and if ASSHELP_FLAG_AUTOSTART is set.
|
||||
Returns a new assuan context at R_CTX or an error code. */
|
||||
gpg_error_t
|
||||
start_new_keyboxd (assuan_context_t *r_ctx,
|
||||
gpg_err_source_t errsource,
|
||||
const char *keyboxd_program,
|
||||
int autostart, int verbose, int debug,
|
||||
unsigned int flags,
|
||||
int verbose, int debug,
|
||||
gpg_error_t (*status_cb)(ctrl_t, int, ...),
|
||||
ctrl_t status_cb_arg)
|
||||
{
|
||||
return start_new_service (r_ctx, GNUPG_MODULE_NAME_KEYBOXD,
|
||||
errsource, keyboxd_program,
|
||||
NULL, NULL, NULL,
|
||||
autostart, verbose, debug,
|
||||
flags, verbose, debug,
|
||||
status_cb, status_cb_arg);
|
||||
}
|
||||
|
||||
|
||||
/* Try to connect to the dirmngr via a socket. On platforms
|
||||
supporting it, start it up if needed and if AUTOSTART is true.
|
||||
supporting it, start it up if needed and if ASSHELP_FLAG_AUTOSTART is set.
|
||||
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 *dirmngr_program,
|
||||
int autostart, int verbose, int debug,
|
||||
unsigned int flags,
|
||||
int verbose, int debug,
|
||||
gpg_error_t (*status_cb)(ctrl_t, int, ...),
|
||||
ctrl_t status_cb_arg)
|
||||
{
|
||||
#ifndef USE_DIRMNGR_AUTO_START
|
||||
autostart = 0;
|
||||
flags &= ~ASSHELP_FLAG_AUTOSTART; /* Clear flag. */
|
||||
#endif
|
||||
return start_new_service (r_ctx, GNUPG_MODULE_NAME_DIRMNGR,
|
||||
errsource, dirmngr_program,
|
||||
NULL, NULL, NULL,
|
||||
autostart, verbose, debug,
|
||||
flags, verbose, debug,
|
||||
status_cb, status_cb_arg);
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include "util.h"
|
||||
|
||||
/*-- asshelp.c --*/
|
||||
#define ASSHELP_FLAG_AUTOSTART 1 /* Autostart the new service. */
|
||||
|
||||
|
||||
void setup_libassuan_logging (unsigned int *debug_var_address,
|
||||
int (*log_monitor)(assuan_context_t ctx,
|
||||
@ -61,7 +63,8 @@ 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 autostart, int verbose, int debug,
|
||||
unsigned int flags,
|
||||
int verbose, int debug,
|
||||
gpg_error_t (*status_cb)(ctrl_t, int, ...),
|
||||
ctrl_t status_cb_arg);
|
||||
|
||||
@ -71,7 +74,8 @@ gpg_error_t
|
||||
start_new_keyboxd (assuan_context_t *r_ctx,
|
||||
gpg_err_source_t errsource,
|
||||
const char *keyboxd_program,
|
||||
int autostart, int verbose, int debug,
|
||||
unsigned int flags,
|
||||
int verbose, int debug,
|
||||
gpg_error_t (*status_cb)(ctrl_t, int, ...),
|
||||
ctrl_t status_cb_arg);
|
||||
|
||||
@ -81,7 +85,8 @@ gpg_error_t
|
||||
start_new_dirmngr (assuan_context_t *r_ctx,
|
||||
gpg_err_source_t errsource,
|
||||
const char *dirmngr_program,
|
||||
int autostart, int verbose, int debug,
|
||||
unsigned int flags,
|
||||
int verbose, int debug,
|
||||
gpg_error_t (*status_cb)(ctrl_t, int, ...),
|
||||
ctrl_t status_cb_arg);
|
||||
|
||||
|
@ -94,7 +94,8 @@ start_agent (void)
|
||||
agentargs.lc_ctype,
|
||||
agentargs.lc_messages,
|
||||
agentargs.session_env,
|
||||
1, agentargs.verbosity, 0, NULL, NULL);
|
||||
ASSHELP_FLAG_AUTOSTART,
|
||||
agentargs.verbosity, 0, NULL, NULL);
|
||||
if (!err)
|
||||
{
|
||||
/* Tell the agent that we support Pinentry notifications. No
|
||||
|
@ -308,7 +308,7 @@ main (int argc, char **argv )
|
||||
opt.dirmngr_program
|
||||
? opt.dirmngr_program
|
||||
: gnupg_module_name (GNUPG_MODULE_NAME_DIRMNGR),
|
||||
! cmd_ping,
|
||||
cmd_ping? 0 : ASSHELP_FLAG_AUTOSTART,
|
||||
opt.verbose,
|
||||
0,
|
||||
NULL, NULL);
|
||||
|
@ -248,7 +248,8 @@ start_agent (ctrl_t ctrl, int flag_for_card)
|
||||
opt.agent_program,
|
||||
opt.lc_ctype, opt.lc_messages,
|
||||
opt.session_env,
|
||||
opt.autostart, opt.verbose, DBG_IPC,
|
||||
opt.autostart?ASSHELP_FLAG_AUTOSTART:0,
|
||||
opt.verbose, DBG_IPC,
|
||||
NULL, NULL);
|
||||
if (!opt.autostart && gpg_err_code (rc) == GPG_ERR_NO_AGENT)
|
||||
{
|
||||
|
@ -166,7 +166,8 @@ create_context (ctrl_t ctrl, assuan_context_t *r_ctx)
|
||||
err = start_new_dirmngr (&ctx,
|
||||
GPG_ERR_SOURCE_DEFAULT,
|
||||
opt.dirmngr_program,
|
||||
opt.autostart, opt.verbose, DBG_IPC,
|
||||
opt.autostart?ASSHELP_FLAG_AUTOSTART:0,
|
||||
opt.verbose, DBG_IPC,
|
||||
NULL /*gpg_status2*/, ctrl);
|
||||
if (!opt.autostart && gpg_err_code (err) == GPG_ERR_NO_DIRMNGR)
|
||||
{
|
||||
|
@ -150,7 +150,8 @@ create_new_context (ctrl_t ctrl, assuan_context_t *r_ctx)
|
||||
err = start_new_keyboxd (&ctx,
|
||||
GPG_ERR_SOURCE_DEFAULT,
|
||||
opt.keyboxd_program,
|
||||
opt.autostart, opt.verbose, DBG_IPC,
|
||||
opt.autostart?ASSHELP_FLAG_AUTOSTART:0,
|
||||
opt.verbose, DBG_IPC,
|
||||
NULL, ctrl);
|
||||
if (!opt.autostart && gpg_err_code (err) == GPG_ERR_NO_KEYBOXD)
|
||||
{
|
||||
|
@ -118,7 +118,8 @@ start_agent (ctrl_t ctrl)
|
||||
opt.agent_program,
|
||||
opt.lc_ctype, opt.lc_messages,
|
||||
opt.session_env,
|
||||
opt.autostart, opt.verbose, DBG_IPC,
|
||||
opt.autostart?ASSHELP_FLAG_AUTOSTART:0,
|
||||
opt.verbose, DBG_IPC,
|
||||
gpgsm_status2, ctrl);
|
||||
|
||||
if (!opt.autostart && gpg_err_code (rc) == GPG_ERR_NO_AGENT)
|
||||
|
@ -228,7 +228,8 @@ start_dirmngr_ext (ctrl_t ctrl, assuan_context_t *ctx_r)
|
||||
|
||||
err = start_new_dirmngr (&ctx, GPG_ERR_SOURCE_DEFAULT,
|
||||
opt.dirmngr_program,
|
||||
opt.autostart, opt.verbose, DBG_IPC,
|
||||
opt.autostart?ASSHELP_FLAG_AUTOSTART:0,
|
||||
opt.verbose, DBG_IPC,
|
||||
gpgsm_status2, ctrl);
|
||||
if (!opt.autostart && gpg_err_code (err) == GPG_ERR_NO_DIRMNGR)
|
||||
{
|
||||
|
@ -523,7 +523,8 @@ create_new_context (ctrl_t ctrl, assuan_context_t *r_ctx)
|
||||
err = start_new_keyboxd (&ctx,
|
||||
GPG_ERR_SOURCE_DEFAULT,
|
||||
opt.keyboxd_program,
|
||||
opt.autostart, opt.verbose, DBG_IPC,
|
||||
opt.autostart?ASSHELP_FLAG_AUTOSTART:0,
|
||||
opt.verbose, DBG_IPC,
|
||||
NULL, ctrl);
|
||||
if (!opt.autostart && gpg_err_code (err) == GPG_ERR_NO_KEYBOXD)
|
||||
{
|
||||
|
@ -65,7 +65,8 @@ connect_dirmngr (assuan_context_t *r_ctx)
|
||||
err = start_new_dirmngr (&ctx,
|
||||
GPG_ERR_SOURCE_DEFAULT,
|
||||
NULL,
|
||||
opt.autostart, opt.verbose, opt.debug_ipc,
|
||||
opt.autostart?ASSHELP_FLAG_AUTOSTART:0,
|
||||
opt.verbose, opt.debug_ipc,
|
||||
NULL, NULL);
|
||||
if (!opt.autostart && gpg_err_code (err) == GPG_ERR_NO_DIRMNGR)
|
||||
{
|
||||
|
@ -299,7 +299,8 @@ start_agent (unsigned int flags)
|
||||
opt.agent_program,
|
||||
opt.lc_ctype, opt.lc_messages,
|
||||
opt.session_env,
|
||||
opt.autostart, opt.verbose, DBG_IPC,
|
||||
opt.autostart?ASSHELP_FLAG_AUTOSTART:0,
|
||||
opt.verbose, DBG_IPC,
|
||||
NULL, NULL);
|
||||
if (!opt.autostart && gpg_err_code (err) == GPG_ERR_NO_AGENT)
|
||||
{
|
||||
|
@ -396,7 +396,7 @@ start_agent (assuan_context_t *ctx_p)
|
||||
opt.agent_program,
|
||||
NULL, NULL,
|
||||
session_env,
|
||||
opt.autostart,
|
||||
opt.autostart?ASSHELP_FLAG_AUTOSTART:0,
|
||||
!opt.quiet, 0,
|
||||
NULL, NULL);
|
||||
|
||||
|
@ -2341,14 +2341,14 @@ start_agent (void)
|
||||
err = start_new_dirmngr (&ctx,
|
||||
GPG_ERR_SOURCE_DEFAULT,
|
||||
opt.dirmngr_program,
|
||||
opt.autostart,
|
||||
opt.autostart?ASSHELP_FLAG_AUTOSTART:0,
|
||||
!opt.quiet, 0,
|
||||
NULL, NULL);
|
||||
else if (opt.use_keyboxd)
|
||||
err = start_new_keyboxd (&ctx,
|
||||
GPG_ERR_SOURCE_DEFAULT,
|
||||
opt.keyboxd_program,
|
||||
opt.autostart,
|
||||
opt.autostart?ASSHELP_FLAG_AUTOSTART:0,
|
||||
!opt.quiet, 0,
|
||||
NULL, NULL);
|
||||
else
|
||||
@ -2357,7 +2357,7 @@ start_agent (void)
|
||||
opt.agent_program,
|
||||
NULL, NULL,
|
||||
session_env,
|
||||
opt.autostart,
|
||||
opt.autostart?ASSHELP_FLAG_AUTOSTART:0,
|
||||
!opt.quiet, 0,
|
||||
NULL, NULL);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user