summaryrefslogtreecommitdiffstats
path: root/scd
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2024-09-05 06:37:21 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2024-09-05 06:37:21 +0200
commitc9677e9501709944e43c88b1af36a74377afa834 (patch)
tree942b9eb51df038de91293f7643ec36b5ea06b3ff /scd
parentgpgconf: Add missing linefeed to the -X output. (diff)
downloadgnupg2-c9677e9501709944e43c88b1af36a74377afa834.tar.xz
gnupg2-c9677e9501709944e43c88b1af36a74377afa834.zip
scd:w32: Export GNUPGHOME for scd-event.
* scd/app.c (report_change): Set up GNUPGHOME. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'scd')
-rw-r--r--scd/app.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/scd/app.c b/scd/app.c
index c2ff50285..ebba472c2 100644
--- a/scd/app.c
+++ b/scd/app.c
@@ -2460,16 +2460,6 @@ app_check_pin (card_t card, ctrl_t ctrl, const char *keyidstr,
return err;
}
-#ifndef HAVE_W32_SYSTEM
-static void
-setup_env (void *arg)
-{
- char *v = arg;
-
- putenv (v);
-}
-#endif
-
static void
report_change (int slot, int old_status, int cur_status)
{
@@ -2492,7 +2482,13 @@ report_change (int slot, int old_status, int cur_status)
xfree (fname);
homestr = make_filename (gnupg_homedir (), NULL);
+#ifdef HAVE_W32_SYSTEM
+ /* An environment block is terminated by two/four zero bytes. It's
+ * four zero bytes for Unicode. Let us always use four zero bytes. */
+ if (gpgrt_asprintf (&envstr, "GNUPGHOME=%s%c%c%c", homestr, 0, 0, 0) < 0)
+#else
if (gpgrt_asprintf (&envstr, "GNUPGHOME=%s", homestr) < 0)
+#endif
log_error ("out of core while building environment\n");
else
{
@@ -2520,8 +2516,11 @@ report_change (int slot, int old_status, int cur_status)
err = gpgrt_spawn_actions_new (&act);
if (!err)
{
-#ifndef HAVE_W32_SYSTEM
- gpgrt_spawn_actions_set_atfork (act, setup_env, envstr);
+#ifdef HAVE_W32_SYSTEM
+ gpgrt_spawn_actions_set_envvars (act, envstr);
+#else
+ char *env[2] = { envstr, NULL };
+ gpgrt_spawn_actions_set_environ (act, env);
#endif
err = gpgrt_process_spawn (fname, args, GPGRT_PROCESS_DETACHED,
act, NULL);