Skip to content

Commit

Permalink
Bug 1263017, CKR_DEVICE_ERROR after fork() when NSS was initialized b…
Browse files Browse the repository at this point in the history
…y someone else, r=kaie
  • Loading branch information
rjrelyea committed Oct 27, 2016
1 parent 550838c commit e2e7786
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/nss/nssinit.c
Expand Up @@ -662,6 +662,21 @@ nss_Init(const char *configdir, const char *certPrefix, const char *keyPrefix,
configName = initParams->libraryDescription;
passwordRequired = initParams->passwordRequired;
}

/* If we're NSS_ContextInit, we're probably a library. It could be
* possible that the application initialized NSS then forked(). The
* library would have no knowledge of that. If we call
* SECMOD_RestartModules() here, we will be able to continue on with
* NSS as normal. SECMOD_RestartModules() does have the side affect
* of losing all our PKCS #11 objects in the new process, but only if
* the module needs to be reinited. If it needs to be reinit those
* objects are inaccessible anyway, it's always save to call
* SECMOD_RestartModules(PR_FALSE).
*/
/* NOTE: We could call SECMOD_Init() here, but if we aren't already
* inited, then there's no modules to restart, so SECMOD_RestartModules
* will return immediately */
SECMOD_RestartModules(PR_FALSE);
} else {
configStrings = pk11_config_strings;
configName = pk11_config_name;
Expand Down

0 comments on commit e2e7786

Please sign in to comment.