admserv/cgi-src40/security.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
New commits:
commit 544b46e49928e60cbe94aea3af6688350fdf94ee
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Apr 24 14:12:46 2015 -0700
Ticket #48153 - [adminserver] support NSS 3.18
Description: The security CGI had some issues when it fails to open/
load the NSS cert db. This patch makes sure that if opening the db
fails, the security CGI correctly reports an error and quits.
https://fedorahosted.org/389/ticket/48153
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
diff --git a/admserv/cgi-src40/security.c b/admserv/cgi-src40/security.c
index 8575d56..d604f88 100644
--- a/admserv/cgi-src40/security.c
+++ b/admserv/cgi-src40/security.c
@@ -234,12 +234,12 @@ static void closeAllSecurityDB() {
/* close all db */
if (NSS_IsInitialized()) {
SSL_ClearSessionCache();
- }
- if (NSS_Shutdown()) {
- PR_snprintf(line, sizeof(line), getResourceString(CMN_NSS_SHUTDOWN_ERROR),
- PR_GetError(),
- SSL_Strerror(PR_GetError()) ? SSL_Strerror(PR_GetError()) :
"unknown");
- rpt_warning(GENERAL_FAILURE, line, NULL, NULL);
+ if (NSS_Shutdown()) {
+ PR_snprintf(line, sizeof(line), getResourceString(CMN_NSS_SHUTDOWN_ERROR),
+ PR_GetError(),
+ SSL_Strerror(PR_GetError()) ? SSL_Strerror(PR_GetError()) :
"unknown");
+ rpt_warning(GENERAL_FAILURE, line, NULL, NULL);
+ }
}
}
@@ -256,6 +256,7 @@ static void errorRpt(int type, char* detailInfo) {
getResourceString(DBT_ERROR_OCCURED),
detailInfo,
NULL);
+ exit(0); /* Make sure it really exits */
}
static void errorRptExtended(int type, char* detail, char* extra) {
@@ -264,6 +265,7 @@ static void errorRptExtended(int type, char* detail, char* extra) {
getResourceString(DBT_ERROR_OCCURED),
detail,
extra);
+ exit(0); /* Make sure it really exits */
}
/* return true if all of the chars in s are valid chars for use in
@@ -1037,6 +1039,12 @@ static void securityInitialization(char* securitydir) {
/* Set certdb handle */
certdb = CERT_GetDefaultCertDB();
+ if (!certdb) {
+ PR_snprintf(line, sizeof(line), getResourceString(CMN_SSL_INIT_ERROR),
+ securitydir ? securitydir : "(null)", PR_GetError(),
+ SSL_Strerror(PR_GetError()) ? SSL_Strerror(PR_GetError()) :
"unknown");
+ errorRpt(GENERAL_FAILURE, line);
+ }
/* set password function */
PK11_SetPasswordFunc(getPassword_cb);
@@ -2143,7 +2151,7 @@ int main(int argc, char *argv[])
if (!operation) {
/* if we got here it means front end pass back
- a bogus operation string */
+ a bogus operation string */
PR_snprintf(line, sizeof(line), getResourceString(DBT_NO_OP), operation);
errorRpt(INCORRECT_USAGE, line);
} else if (!PORT_Strcmp(operation, "MIGRATE_DB")) {