diff options
author | NIIBE Yutaka <[email protected]> | 2016-10-04 00:01:13 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2016-10-04 00:01:13 +0000 |
commit | eda17649f8bd3b8ce7bfc00a3c11cbcae63c845d (patch) | |
tree | 07b0c81acce42597ce8b856f3b16b4845c8c2eab /dirmngr/dirmngr.c | |
parent | agent: Remove the warning for the GKR hijacking. (diff) | |
download | gnupg-eda17649f8bd3b8ce7bfc00a3c11cbcae63c845d.tar.gz gnupg-eda17649f8bd3b8ce7bfc00a3c11cbcae63c845d.zip |
agent, dirmngr, scd: npth_init must be after fork.
* agent/gpg-agent.c (thread_init_once, initialize_modules): New.
(main): Make sure no daemonizing-fork call after npth_init, and no npth
calls before npth_init, with care of npth calls by assuan hooks.
* dirmngr/dirmngr.c (thread_init): New.
(main): Make sure npth_init must not be called before daemonizing fork.
* scd/scdaemon.c (main): Likewise.
--
It is simply the best for nPth not to allow the daemonizing fork after
npth_init, because semantics and implementations of forked child process
in a threaded application is a difficult corner case.
GnuPG-bug-id: 1779
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to '')
-rw-r--r-- | dirmngr/dirmngr.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c index 64d93b7cf..621c2bb9a 100644 --- a/dirmngr/dirmngr.c +++ b/dirmngr/dirmngr.c @@ -647,6 +647,22 @@ pid_suffix_callback (unsigned long *r_suffix) #endif /*!HAVE_W32_SYSTEM*/ +static void +thread_init (void) +{ + npth_init (); + + /* Now with NPth running we can set the logging callback. Our + windows implementation does not yet feature the NPth TLS + functions. */ +#ifndef HAVE_W32_SYSTEM + if (npth_key_create (&my_tlskey_current_fd, NULL) == 0) + if (npth_setspecific (my_tlskey_current_fd, NULL) == 0) + log_set_pid_suffix_cb (pid_suffix_callback); +#endif /*!HAVE_W32_SYSTEM*/ +} + + int main (int argc, char **argv) { @@ -680,8 +696,6 @@ main (int argc, char **argv) i18n_init (); init_common_subsystems (&argc, &argv); - npth_init (); - gcry_control (GCRYCTL_DISABLE_SECMEM, 0); /* Check that the libraries are suitable. Do it here because @@ -722,15 +736,6 @@ main (int argc, char **argv) if (shell && strlen (shell) >= 3 && !strcmp (shell+strlen (shell)-3, "csh") ) csh_style = 1; - /* Now with NPth running we can set the logging callback. Our - windows implementation does not yet feature the NPth TLS - functions. */ -#ifndef HAVE_W32_SYSTEM - if (npth_key_create (&my_tlskey_current_fd, NULL) == 0) - if (npth_setspecific (my_tlskey_current_fd, NULL) == 0) - log_set_pid_suffix_cb (pid_suffix_callback); -#endif /*!HAVE_W32_SYSTEM*/ - /* Reset rereadable options to default values. */ parse_rereadable_options (NULL, 0); @@ -981,6 +986,7 @@ main (int argc, char **argv) ldap_wrapper_launch_thread (); #endif /*USE_LDAP*/ + thread_init (); cert_cache_init (); crl_cache_init (); start_command_handler (ASSUAN_INVALID_FD); @@ -1179,6 +1185,7 @@ main (int argc, char **argv) ldap_wrapper_launch_thread (); #endif /*USE_LDAP*/ + thread_init (); cert_cache_init (); crl_cache_init (); handle_connections (fd); @@ -1206,6 +1213,7 @@ main (int argc, char **argv) #if USE_LDAP ldap_wrapper_launch_thread (); #endif /*USE_LDAP*/ + thread_init (); cert_cache_init (); crl_cache_init (); if (!argc) @@ -1231,6 +1239,7 @@ main (int argc, char **argv) #if USE_LDAP ldap_wrapper_launch_thread (); #endif /*USE_LDAP*/ + thread_init (); cert_cache_init (); crl_cache_init (); rc = crl_fetch (&ctrlbuf, argv[0], &reader); |