mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
agent: separate out daemon handling infrastructure for reuse
* agent/call-scd.c: Factor re-usable code out to ... * agent/call-daemon.c: new. Store infos in an array to allow for other backend daemons. * agent/Makefile.am (gpg_agent_SOURCES): Add new file. * agent/agent.h: Include assuan.h. (enum daemon_type): New. (opt): Replace scdaemon_program by daemon_program array. Replace scd_local by a array d_local. Change users accordingly. -- The model I'm using for a TPM daemon is the current scdaemon. That includes start and stop handlers plus liveness checks and an assuan socket generator. To avoid massive code duplication (and save me a lot of effort), I've elected to strip this code out of call-scd.c into a generic framework which can then be reused as is by the TPM handling daemon. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Co-authored-by: Werner Koch <wk@gnupg.org> Modified original patch for 2.2 heavily to fit the new framework used in master (gnupg 2.3) Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
2d8f060679
commit
f541e1d95a
7 changed files with 759 additions and 583 deletions
|
@ -845,7 +845,7 @@ parse_rereadable_options (gpgrt_argparse_t *pargs, int reread)
|
|||
xfree (opt.pinentry_invisible_char);
|
||||
opt.pinentry_invisible_char = NULL;
|
||||
opt.pinentry_timeout = 0;
|
||||
opt.scdaemon_program = NULL;
|
||||
memset (opt.daemon_program, 0, sizeof opt.daemon_program);
|
||||
opt.def_cache_ttl = DEFAULT_CACHE_TTL;
|
||||
opt.def_cache_ttl_ssh = DEFAULT_CACHE_TTL_SSH;
|
||||
opt.max_cache_ttl = MAX_CACHE_TTL;
|
||||
|
@ -862,7 +862,7 @@ parse_rereadable_options (gpgrt_argparse_t *pargs, int reread)
|
|||
opt.allow_external_cache = 1;
|
||||
opt.allow_loopback_pinentry = 1;
|
||||
opt.allow_emacs_pinentry = 0;
|
||||
opt.disable_scdaemon = 0;
|
||||
memset (opt.disable_daemon, 0, sizeof opt.disable_daemon);
|
||||
disable_check_own_socket = 0;
|
||||
/* Note: When changing the next line, change also gpgconf_list. */
|
||||
opt.ssh_fingerprint_digest = GCRY_MD_MD5;
|
||||
|
@ -905,8 +905,8 @@ parse_rereadable_options (gpgrt_argparse_t *pargs, int reread)
|
|||
opt.pinentry_invisible_char = xtrystrdup (pargs->r.ret_str); break;
|
||||
break;
|
||||
case oPinentryTimeout: opt.pinentry_timeout = pargs->r.ret_ulong; break;
|
||||
case oScdaemonProgram: opt.scdaemon_program = pargs->r.ret_str; break;
|
||||
case oDisableScdaemon: opt.disable_scdaemon = 1; break;
|
||||
case oScdaemonProgram: opt.daemon_program[DAEMON_SCD] = pargs->r.ret_str; break;
|
||||
case oDisableScdaemon: opt.disable_daemon[DAEMON_SCD] = 1; break;
|
||||
case oDisableCheckOwnSocket: disable_check_own_socket = 1; break;
|
||||
|
||||
case oDefCacheTTL: opt.def_cache_ttl = pargs->r.ret_ulong; break;
|
||||
|
@ -1020,7 +1020,7 @@ initialize_modules (void)
|
|||
assuan_set_system_hooks (ASSUAN_SYSTEM_NPTH);
|
||||
initialize_module_cache ();
|
||||
initialize_module_call_pinentry ();
|
||||
initialize_module_call_scd ();
|
||||
initialize_module_daemon ();
|
||||
initialize_module_trustlist ();
|
||||
}
|
||||
|
||||
|
@ -2064,7 +2064,7 @@ get_agent_active_connection_count (void)
|
|||
event. */
|
||||
#if defined(HAVE_W32_SYSTEM) && !defined(HAVE_W32CE_SYSTEM)
|
||||
void *
|
||||
get_agent_scd_notify_event (void)
|
||||
get_agent_daemon_notify_event (void)
|
||||
{
|
||||
static HANDLE the_event = INVALID_HANDLE_VALUE;
|
||||
|
||||
|
@ -2403,8 +2403,8 @@ agent_sighup_action (void)
|
|||
"pinentry-basic" fallback was in use. */
|
||||
gnupg_module_name_flush_some ();
|
||||
|
||||
if (opt.disable_scdaemon)
|
||||
agent_card_killscd ();
|
||||
if (opt.disable_daemon[DAEMON_SCD])
|
||||
agent_kill_daemon (DAEMON_SCD);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2438,7 +2438,7 @@ handle_signal (int signo)
|
|||
logging system. */
|
||||
/* pth_ctrl (PTH_CTRL_DUMPSTATE, log_get_stream ()); */
|
||||
agent_query_dump_state ();
|
||||
agent_scd_dump_state ();
|
||||
agent_daemon_dump_state ();
|
||||
break;
|
||||
|
||||
case SIGUSR2:
|
||||
|
@ -2841,7 +2841,7 @@ handle_connections (gnupg_fd_t listen_fd,
|
|||
sigs = 0;
|
||||
ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
|
||||
# else
|
||||
events[0] = get_agent_scd_notify_event ();
|
||||
events[0] = get_agent_daemon_notify_event ();
|
||||
events[1] = INVALID_HANDLE_VALUE;
|
||||
# endif
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue