1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

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 <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2016-10-04 09:01:13 +09:00
parent a43739a245
commit eda17649f8
3 changed files with 52 additions and 21 deletions

View file

@ -422,8 +422,6 @@ main (int argc, char **argv )
i18n_init ();
init_common_subsystems (&argc, &argv);
npth_init ();
ksba_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free);
malloc_hooks.malloc = gcry_malloc;
@ -724,6 +722,8 @@ main (int argc, char **argv )
}
#endif
npth_init ();
/* If --debug-allow-core-dump has been given we also need to
switch the working directory to a place where we can actually
write. */
@ -861,6 +861,8 @@ main (int argc, char **argv )
/* This is the child. */
npth_init ();
/* Detach from tty and put process into a new session. */
if (!nodetach )
{