mirror of
https://github.com/ceph/ceph
synced 2025-01-03 01:22:53 +00:00
auth: reinitialize NSS modules after fork()
Fixes: #11128 Signed-off-by: Yan, Zheng <zyan@redhat.com>
This commit is contained in:
parent
f183cd7c21
commit
4c24d0cc07
@ -37,14 +37,24 @@ ceph::crypto::HMACSHA1::~HMACSHA1()
|
||||
|
||||
#elif USE_NSS
|
||||
|
||||
// for SECMOD_RestartModules()
|
||||
#include <secmod.h>
|
||||
|
||||
// Initialization of NSS requires a mutex due to a race condition in
|
||||
// NSS_NoDB_Init.
|
||||
static pthread_mutex_t crypto_init_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pid_t crypto_init_pid = 0;
|
||||
|
||||
void ceph::crypto::init(CephContext *cct)
|
||||
{
|
||||
pid_t pid = getpid();
|
||||
SECStatus s;
|
||||
pthread_mutex_lock(&crypto_init_mutex);
|
||||
if (crypto_init_pid != pid) {
|
||||
if (crypto_init_pid > 0)
|
||||
SECMOD_RestartModules(PR_FALSE);
|
||||
crypto_init_pid = pid;
|
||||
}
|
||||
if (cct->_conf->nss_db_path.empty()) {
|
||||
s = NSS_NoDB_Init(NULL);
|
||||
} else {
|
||||
@ -59,6 +69,7 @@ void ceph::crypto::shutdown()
|
||||
SECStatus s;
|
||||
s = NSS_Shutdown();
|
||||
assert(s == SECSuccess);
|
||||
crypto_init_pid = 0;
|
||||
}
|
||||
|
||||
ceph::crypto::HMACSHA1::~HMACSHA1()
|
||||
|
Loading…
Reference in New Issue
Block a user