aboutsummaryrefslogtreecommitdiffstats
path: root/scd
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2024-05-31 06:36:39 +0000
committerNIIBE Yutaka <[email protected]>2024-05-31 06:36:39 +0000
commitfc3fde1bdeb260c92b0a3ea7489536129e9a8a93 (patch)
treed5eb2a841f582211f48dc155f4fd079ea4ead597 /scd
parentcommon: Fix process termination check at release. (diff)
downloadgnupg-fc3fde1bdeb260c92b0a3ea7489536129e9a8a93.tar.gz
gnupg-fc3fde1bdeb260c92b0a3ea7489536129e9a8a93.zip
spawn: Remove spawn callback, introduce gnupg_spawn_actions.
* common/exechelp-posix.c (call_spawn_cb): Remove. (gnupg_spawn_actions_new, gnupg_spawn_actions_release) (gnupg_spawn_actions_set_environ, gnupg_spawn_actions_set_atfork) (gnupg_spawn_actions_set_redirect) (gnupg_spawn_actions_set_inherit_fds): New. (my_exec, spawn_detached): Use spawn actions. (gnupg_spawn_helper): Remove. (gnupg_process_spawn): Remove callback, introduce gnupg_spawn_actions. * common/exechelp-w32.c: Ditto. * common/exechelp.h: Ditto. * agent/genkey.c (do_check_passphrase_pattern): Follow the change of gnupg_process_spawn API. * common/asshelp.c (start_new_service): Likewise. * common/exectool.c (gnupg_exec_tool_stream): Likewise. * common/t-exechelp.c (test_pipe_stream): Likewise. * dirmngr/ldap-wrapper.c (ldap_wrapper): Likewise. * g10/photoid.c (run_with_pipe): Likewise. * scd/app.c (report_change): Likewise. * tests/gpgscm/ffi.c (do_process_spawn_io, do_process_spawn_fd): Likewise. * tools/gpg-card.c (cmd_gpg): Likewise. * tools/gpgconf-comp.c (gpg_agent_runtime_change): Likewise. (scdaemon_runtime_change, tpm2daemon_runtime_change) (dirmngr_runtime_change, keyboxd_runtime_change) (gc_component_launch, gc_component_check_options) (retrieve_options_from_program): Likewise. * tools/gpgconf.c (show_versions_via_dirmngr): Likewise. * tools/gpgtar-create.c (gpgtar_create): Likewise. * tools/gpgtar-extract.c (gpgtar_extract): Likewise. * tools/gpgtar-list.c (gpgtar_list): Likewise. -- Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'scd')
-rw-r--r--scd/app.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/scd/app.c b/scd/app.c
index a9591a12c..09a148416 100644
--- a/scd/app.c
+++ b/scd/app.c
@@ -2383,18 +2383,15 @@ app_check_pin (card_t card, ctrl_t ctrl, const char *keyidstr,
return err;
}
-
+#ifndef HAVE_W32_SYSTEM
static void
-setup_env (struct spawn_cb_arg *sca)
+setup_env (void *arg)
{
-#ifdef HAVE_W32_SYSTEM
- (void)sca; /* Not supported on Windows. */
-#else
- char *v = sca->arg;
+ char *v = arg;
putenv (v);
-#endif
}
+#endif
static void
report_change (int slot, int old_status, int cur_status)
@@ -2425,6 +2422,7 @@ report_change (int slot, int old_status, int cur_status)
gpg_error_t err;
const char *args[9];
char numbuf1[30], numbuf2[30], numbuf3[30];
+ gnupg_spawn_actions_t act = NULL;
sprintf (numbuf1, "%d", slot);
sprintf (numbuf2, "0x%04X", old_status);
@@ -2442,9 +2440,16 @@ report_change (int slot, int old_status, int cur_status)
args[8] = NULL;
fname = make_filename (gnupg_homedir (), "scd-event", NULL);
- err = gnupg_process_spawn (fname, args,
- GNUPG_PROCESS_DETACHED,
- setup_env, envstr, NULL);
+ err = gnupg_spawn_actions_new (&act);
+ if (!err)
+ {
+#ifndef HAVE_W32_SYSTEM
+ gnupg_spawn_actions_set_atfork (act, setup_env, envstr);
+#endif
+ err = gnupg_process_spawn (fname, args, GNUPG_PROCESS_DETACHED,
+ act, NULL);
+ gnupg_spawn_actions_release (act);
+ }
if (err && gpg_err_code (err) != GPG_ERR_ENOENT)
log_error ("failed to run event handler '%s': %s\n",
fname, gpg_strerror (err));