diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-07-11 15:36:54 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-07-13 12:35:22 -0400 |
commit | d811ce2421dcf1684db7e34f2b5998d9f360d5fb (patch) | |
tree | f914d9ef7ab706dac95279ce4c95f8e8b0fd5535 /src/lib/crypt_ops | |
parent | c317e78dd75b6bf9c195c9bef5a0b8300d55411a (diff) | |
download | tor-d811ce2421dcf1684db7e34f2b5998d9f360d5fb.tar.gz tor-d811ce2421dcf1684db7e34f2b5998d9f360d5fb.zip |
Add postfork support for nss
We need this in our unit tests, since otherwise NSS will notice
we've forked and start cussing us out.
I suspect we'll need a different hack for daemonizing, but this
should be enough for tinytest to work.
Diffstat (limited to 'src/lib/crypt_ops')
-rw-r--r-- | src/lib/crypt_ops/crypto_init.c | 10 | ||||
-rw-r--r-- | src/lib/crypt_ops/crypto_init.h | 1 | ||||
-rw-r--r-- | src/lib/crypt_ops/crypto_nss_mgt.c | 7 | ||||
-rw-r--r-- | src/lib/crypt_ops/crypto_nss_mgt.h | 2 |
4 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/crypt_ops/crypto_init.c b/src/lib/crypt_ops/crypto_init.c index 7f5a63219b..b651474cf8 100644 --- a/src/lib/crypt_ops/crypto_init.c +++ b/src/lib/crypt_ops/crypto_init.c @@ -127,3 +127,13 @@ crypto_global_cleanup(void) return 0; } + +/** Run operations that the crypto library requires to be happy again + * after forking. */ +void +crypto_postfork(void) +{ +#ifdef ENABLE_NSS + crypto_nss_postfork(); +#endif +} diff --git a/src/lib/crypt_ops/crypto_init.h b/src/lib/crypt_ops/crypto_init.h index e450e2d894..3e32456b5c 100644 --- a/src/lib/crypt_ops/crypto_init.h +++ b/src/lib/crypt_ops/crypto_init.h @@ -24,5 +24,6 @@ int crypto_global_init(int hardwareAccel, void crypto_thread_cleanup(void); int crypto_global_cleanup(void); +void crypto_postfork(void); #endif /* !defined(TOR_CRYPTO_H) */ diff --git a/src/lib/crypt_ops/crypto_nss_mgt.c b/src/lib/crypt_ops/crypto_nss_mgt.c index 84d9f027a4..6bcaeabd5a 100644 --- a/src/lib/crypt_ops/crypto_nss_mgt.c +++ b/src/lib/crypt_ops/crypto_nss_mgt.c @@ -93,3 +93,10 @@ crypto_nss_global_cleanup(void) { NSS_Shutdown(); } + +void +crypto_nss_postfork(void) +{ + crypto_nss_global_cleanup(); + crypto_nss_early_init(); +} diff --git a/src/lib/crypt_ops/crypto_nss_mgt.h b/src/lib/crypt_ops/crypto_nss_mgt.h index 0e899bad06..c4c94f4d89 100644 --- a/src/lib/crypt_ops/crypto_nss_mgt.h +++ b/src/lib/crypt_ops/crypto_nss_mgt.h @@ -26,6 +26,8 @@ void crypto_nss_early_init(void); int crypto_nss_late_init(void); void crypto_nss_global_cleanup(void); + +void crypto_nss_postfork(void); #endif #endif /* !defined(TOR_CRYPTO_NSS_H) */ |