| OLD | NEW |
| 1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 /* | 4 /* |
| 5 * The following code handles the storage of PKCS 11 modules used by the | 5 * The following code handles the storage of PKCS 11 modules used by the |
| 6 * NSS. For the rest of NSS, only one kind of database handle exists: | 6 * NSS. For the rest of NSS, only one kind of database handle exists: |
| 7 * | 7 * |
| 8 * SFTKDBHandle | 8 * SFTKDBHandle |
| 9 * | 9 * |
| 10 * There is one SFTKDBHandle for the each key database and one for each cert | 10 * There is one SFTKDBHandle for each key database and one for each cert |
| 11 * database. These databases are opened as associated pairs, one pair per | 11 * database. These databases are opened as associated pairs, one pair per |
| 12 * slot. SFTKDBHandles are reference counted objects. | 12 * slot. SFTKDBHandles are reference counted objects. |
| 13 * | 13 * |
| 14 * Each SFTKDBHandle points to a low level database handle (SDB). This handle | 14 * Each SFTKDBHandle points to a low level database handle (SDB). This handle |
| 15 * represents the underlying physical database. These objects are not | 15 * represents the underlying physical database. These objects are not |
| 16 * reference counted, an are 'owned' by their respective SFTKDBHandles. | 16 * reference counted, and are 'owned' by their respective SFTKDBHandles. |
| 17 * | |
| 18 * | |
| 19 */ | 17 */ |
| 20 #include "sftkdb.h" | 18 |
| 21 #include "sftkpars.h" | |
| 22 #include "prprf.h" | 19 #include "prprf.h" |
| 23 #include "prsystem.h" | 20 #include "prsystem.h" |
| 24 #include "lgglue.h" | 21 #include "lgglue.h" |
| 22 #include "utilpars.h" |
| 25 #include "secerr.h" | 23 #include "secerr.h" |
| 26 #include "secmodt.h" | |
| 27 #if defined (_WIN32) | 24 #if defined (_WIN32) |
| 28 #include <io.h> | 25 #include <io.h> |
| 29 #endif | 26 #endif |
| 30 | 27 |
| 31 /**************************************************************** | 28 /**************************************************************** |
| 32 * | 29 * |
| 33 * Secmod database. | 30 * Secmod database. |
| 34 * | 31 * |
| 35 * The new secmod database is simply a text file with each of the module | 32 * The new secmod database is simply a text file with each of the module |
| 36 * entries. in the following form: | 33 * entries in the following form: |
| 37 * | 34 * |
| 38 * # | 35 * # |
| 39 * # This is a comment The next line is the library to load | 36 * # This is a comment The next line is the library to load |
| 40 * library=libmypkcs11.so | 37 * library=libmypkcs11.so |
| 41 * name="My PKCS#11 module" | 38 * name="My PKCS#11 module" |
| 42 * params="my library's param string" | 39 * params="my library's param string" |
| 43 * nss="NSS parameters" | 40 * nss="NSS parameters" |
| 44 * other="parameters for other libraries and applications" | 41 * other="parameters for other libraries and applications" |
| 45 * | 42 * |
| 46 * library=libmynextpk11.so | 43 * library=libmynextpk11.so |
| 47 * name="My other PKCS#11 module" | 44 * name="My other PKCS#11 module" |
| 48 */ | 45 */ |
| 49 | 46 |
| 50 static char * | |
| 51 sftkdb_quote(const char *string, char quote) | |
| 52 { | |
| 53 char *newString = 0; | |
| 54 int escapes = 0, size = 0; | |
| 55 const char *src; | |
| 56 char *dest; | |
| 57 | |
| 58 size=2; | |
| 59 for (src=string; *src ; src++) { | |
| 60 if ((*src == quote) || (*src == '\\')) escapes++; | |
| 61 size++; | |
| 62 } | |
| 63 | |
| 64 dest = newString = PORT_ZAlloc(escapes+size+1); | |
| 65 if (newString == NULL) { | |
| 66 return NULL; | |
| 67 } | |
| 68 | |
| 69 *dest++=quote; | |
| 70 for (src=string; *src; src++,dest++) { | |
| 71 if ((*src == '\\') || (*src == quote)) { | |
| 72 *dest++ = '\\'; | |
| 73 } | |
| 74 *dest = *src; | |
| 75 } | |
| 76 *dest=quote; | |
| 77 | |
| 78 return newString; | |
| 79 } | |
| 80 | 47 |
| 81 /* | 48 /* |
| 82 * Smart string cat functions. Automatically manage the memory. | 49 * Smart string cat functions. Automatically manage the memory. |
| 83 * The first parameter is the source string. If it's null, we | 50 * The first parameter is the source string. If it's null, we |
| 84 * allocate memory for it. If it's not, we reallocate memory | 51 * allocate memory for it. If it's not, we reallocate memory |
| 85 * so the the concanenated string fits. | 52 * so the the concanenated string fits. |
| 86 */ | 53 */ |
| 87 static char * | 54 static char * |
| 88 sftkdb_DupnCat(char *baseString, const char *str, int str_len) | 55 nssutil_DupnCat(char *baseString, const char *str, int str_len) |
| 89 { | 56 { |
| 90 int len = (baseString ? PORT_Strlen(baseString) : 0) + 1; | 57 int len = (baseString ? PORT_Strlen(baseString) : 0) + 1; |
| 91 char *newString; | 58 char *newString; |
| 92 | 59 |
| 93 len += str_len; | 60 len += str_len; |
| 94 newString = (char *) PORT_Realloc(baseString,len); | 61 newString = (char *) PORT_Realloc(baseString,len); |
| 95 if (newString == NULL) { | 62 if (newString == NULL) { |
| 96 PORT_Free(baseString); | 63 PORT_Free(baseString); |
| 97 return NULL; | 64 return NULL; |
| 98 } | 65 } |
| 99 if (baseString == NULL) *newString = 0; | 66 if (baseString == NULL) *newString = 0; |
| 100 return PORT_Strncat(newString,str, str_len); | 67 return PORT_Strncat(newString,str, str_len); |
| 101 } | 68 } |
| 102 | 69 |
| 103 /* Same as sftkdb_DupnCat except it concatenates the full string, not a | 70 /* Same as nssutil_DupnCat except it concatenates the full string, not a |
| 104 * partial one */ | 71 * partial one */ |
| 105 static char * | 72 static char * |
| 106 sftkdb_DupCat(char *baseString, const char *str) | 73 nssutil_DupCat(char *baseString, const char *str) |
| 107 { | 74 { |
| 108 return sftkdb_DupnCat(baseString, str, PORT_Strlen(str)); | 75 return nssutil_DupnCat(baseString, str, PORT_Strlen(str)); |
| 109 } | 76 } |
| 110 | 77 |
| 111 /* function to free up all the memory associated with a null terminated | 78 /* function to free up all the memory associated with a null terminated |
| 112 * array of module specs */ | 79 * array of module specs */ |
| 113 static SECStatus | 80 static SECStatus |
| 114 sftkdb_releaseSpecList(char **moduleSpecList) | 81 nssutil_releaseSpecList(char **moduleSpecList) |
| 115 { | 82 { |
| 116 if (moduleSpecList) { | 83 if (moduleSpecList) { |
| 117 char **index; | 84 char **index; |
| 118 for(index = moduleSpecList; *index; index++) { | 85 for(index = moduleSpecList; *index; index++) { |
| 119 PORT_Free(*index); | 86 PORT_Free(*index); |
| 120 } | 87 } |
| 121 PORT_Free(moduleSpecList); | 88 PORT_Free(moduleSpecList); |
| 122 } | 89 } |
| 123 return SECSuccess; | 90 return SECSuccess; |
| 124 } | 91 } |
| 125 | 92 |
| 126 #define SECMOD_STEP 10 | 93 #define SECMOD_STEP 10 |
| 127 static SECStatus | 94 static SECStatus |
| 128 sftkdb_growList(char ***pModuleList, int *useCount, int last) | 95 nssutil_growList(char ***pModuleList, int *useCount, int last) |
| 129 { | 96 { |
| 130 char **newModuleList; | 97 char **newModuleList; |
| 131 | 98 |
| 132 *useCount += SECMOD_STEP; | 99 *useCount += SECMOD_STEP; |
| 133 newModuleList = (char **)PORT_Realloc(*pModuleList, | 100 newModuleList = (char **)PORT_Realloc(*pModuleList, |
| 134 *useCount*sizeof(char *)); | 101 *useCount*sizeof(char *)); |
| 135 if (newModuleList == NULL) { | 102 if (newModuleList == NULL) { |
| 136 return SECFailure; | 103 return SECFailure; |
| 137 } | 104 } |
| 138 PORT_Memset(&newModuleList[last],0, sizeof(char *)*SECMOD_STEP); | 105 PORT_Memset(&newModuleList[last],0, sizeof(char *)*SECMOD_STEP); |
| 139 *pModuleList = newModuleList; | 106 *pModuleList = newModuleList; |
| 140 return SECSuccess; | 107 return SECSuccess; |
| 141 } | 108 } |
| 142 | 109 |
| 143 static | 110 static |
| 144 char *sftk_getOldSecmodName(const char *dbname,const char *filename) | 111 char *_NSSUTIL_GetOldSecmodName(const char *dbname,const char *filename) |
| 145 { | 112 { |
| 146 char *file = NULL; | 113 char *file = NULL; |
| 147 char *dirPath = PORT_Strdup(dbname); | 114 char *dirPath = PORT_Strdup(dbname); |
| 148 char *sep; | 115 char *sep; |
| 149 | 116 |
| 150 sep = PORT_Strrchr(dirPath,*PATH_SEPARATOR); | 117 sep = PORT_Strrchr(dirPath,*NSSUTIL_PATH_SEPARATOR); |
| 151 #ifdef _WIN32 | 118 #ifdef WINDOWS |
| 152 if (!sep) { | 119 if (!sep) { |
| 153 /* pkcs11i.h defines PATH_SEPARATOR as "/" for all platforms. */ | |
| 154 sep = PORT_Strrchr(dirPath,'\\'); | 120 sep = PORT_Strrchr(dirPath,'\\'); |
| 155 } | 121 } |
| 156 #endif | 122 #endif |
| 157 if (sep) { | 123 if (sep) { |
| 158 » *sep = 0; | 124 » *(sep)=0; |
| 159 » file = PR_smprintf("%s"PATH_SEPARATOR"%s", dirPath, filename); | |
| 160 } else { | |
| 161 » file = PR_smprintf("%s", filename); | |
| 162 } | 125 } |
| 126 file= PR_smprintf("%s"NSSUTIL_PATH_SEPARATOR"%s", dirPath, filename); |
| 163 PORT_Free(dirPath); | 127 PORT_Free(dirPath); |
| 164 return file; | 128 return file; |
| 165 } | 129 } |
| 166 | 130 |
| 131 static SECStatus nssutil_AddSecmodDB(NSSDBType dbType, const char *appName, |
| 132 const char *filename, const char *dbname, |
| 133 char *module, PRBool rw); |
| 134 |
| 167 #ifdef XP_UNIX | 135 #ifdef XP_UNIX |
| 168 #include <unistd.h> | 136 #include <unistd.h> |
| 169 #endif | 137 #endif |
| 170 #include <fcntl.h> | 138 #include <fcntl.h> |
| 171 | 139 |
| 172 #ifndef WINCE | 140 #ifndef WINCE |
| 173 /* same as fopen, except it doesn't use umask, but explicit */ | 141 /* same as fopen, except it doesn't use umask, but explicit */ |
| 174 FILE * | 142 FILE * |
| 175 lfopen(const char *name, const char *mode, int flags) | 143 lfopen(const char *name, const char *mode, int flags) |
| 176 { | 144 { |
| 177 int fd; | 145 int fd; |
| 178 FILE *file; | 146 FILE *file; |
| 179 | 147 |
| 180 fd = open(name, flags, 0600); | 148 fd = open(name, flags, 0600); |
| 181 if (fd < 0) { | 149 if (fd < 0) { |
| 182 return NULL; | 150 return NULL; |
| 183 } | 151 } |
| 184 file = fdopen(fd, mode); | 152 file = fdopen(fd, mode); |
| 185 if (!file) { | 153 if (!file) { |
| 186 close(fd); | 154 close(fd); |
| 187 } | 155 } |
| 188 /* file inherits fd */ | 156 /* file inherits fd */ |
| 189 return file; | 157 return file; |
| 190 } | 158 } |
| 191 #endif | 159 #endif |
| 192 | 160 |
| 193 #define MAX_LINE_LENGTH 2048 | 161 #define MAX_LINE_LENGTH 2048 |
| 194 #define SFTK_DEFAULT_INTERNAL_INIT1 "library= name=\"NSS Internal PKCS #11 Modul
e\" parameters=" | |
| 195 #define SFTK_DEFAULT_INTERNAL_INIT2 " NSS=\"Flags=internal,critical trustOrder=7
5 cipherOrder=100 slotParams=(1={" | |
| 196 #define SFTK_DEFAULT_INTERNAL_INIT3 " askpw=any timeout=30})\"" | |
| 197 | 162 |
| 198 /* | 163 /* |
| 199 * Read all the existing modules in out of the file. | 164 * Read all the existing modules in out of the file. |
| 200 */ | 165 */ |
| 201 char ** | 166 static char ** |
| 202 sftkdb_ReadSecmodDB(SDBType dbType, const char *appName, | 167 nssutil_ReadSecmodDB(NSSDBType dbType, const char *appName, |
| 203 const char *filename, const char *dbname, | 168 const char *filename, const char *dbname, |
| 204 char *params, PRBool rw) | 169 char *params, PRBool rw) |
| 205 { | 170 { |
| 206 FILE *fd = NULL; | 171 FILE *fd = NULL; |
| 207 char **moduleList = NULL; | 172 char **moduleList = NULL; |
| 208 int moduleCount = 1; | 173 int moduleCount = 1; |
| 209 int useCount = SECMOD_STEP; | 174 int useCount = SECMOD_STEP; |
| 210 char line[MAX_LINE_LENGTH]; | 175 char line[MAX_LINE_LENGTH]; |
| 211 PRBool internal = PR_FALSE; | 176 PRBool internal = PR_FALSE; |
| 212 PRBool skipParams = PR_FALSE; | 177 PRBool skipParams = PR_FALSE; |
| 213 char *moduleString = NULL; | 178 char *moduleString = NULL; |
| 214 char *paramsValue=NULL; | 179 char *paramsValue=NULL; |
| 215 PRBool failed = PR_TRUE; | 180 PRBool failed = PR_TRUE; |
| 216 | 181 |
| 217 if ((dbname != NULL) && | 182 if (dbname == NULL) { |
| 218 » » ((dbType == SDB_LEGACY) || (dbType == SDB_MULTIACCESS))) { | 183 » PORT_SetError(SEC_ERROR_INVALID_ARGS); |
| 219 » return sftkdbCall_ReadSecmodDB(appName, filename, dbname, params, rw); | 184 » return NULL; |
| 220 } | 185 } |
| 221 | 186 |
| 222 moduleList = (char **) PORT_ZAlloc(useCount*sizeof(char **)); | 187 moduleList = (char **) PORT_ZAlloc(useCount*sizeof(char **)); |
| 223 if (moduleList == NULL) return NULL; | 188 if (moduleList == NULL) return NULL; |
| 224 | 189 |
| 225 if (dbname == NULL) { | |
| 226 goto return_default; | |
| 227 } | |
| 228 | |
| 229 /* do we really want to use streams here */ | 190 /* do we really want to use streams here */ |
| 230 fd = fopen(dbname, "r"); | 191 fd = fopen(dbname, "r"); |
| 231 if (fd == NULL) goto done; | 192 if (fd == NULL) goto done; |
| 232 | 193 |
| 233 /* | 194 /* |
| 234 * the following loop takes line separated config lines and collapses | 195 * the following loop takes line separated config lines and collapses |
| 235 * the lines to a single string, escaping and quoting as necessary. | 196 * the lines to a single string, escaping and quoting as necessary. |
| 236 */ | 197 */ |
| 237 /* loop state variables */ | 198 /* loop state variables */ |
| 238 moduleString = NULL; /* current concatenated string */ | 199 moduleString = NULL; /* current concatenated string */ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 255 * The PKCS #11 group standard assumes blocks of strings | 216 * The PKCS #11 group standard assumes blocks of strings |
| 256 * separated by new lines, clumped by new lines. Internally | 217 * separated by new lines, clumped by new lines. Internally |
| 257 * we take strings separated by spaces, so we may need to escape | 218 * we take strings separated by spaces, so we may need to escape |
| 258 * certain spaces. | 219 * certain spaces. |
| 259 */ | 220 */ |
| 260 char *value = PORT_Strchr(line,'='); | 221 char *value = PORT_Strchr(line,'='); |
| 261 | 222 |
| 262 /* there is no value, write out the stanza as is */ | 223 /* there is no value, write out the stanza as is */ |
| 263 if (value == NULL || value[1] == 0) { | 224 if (value == NULL || value[1] == 0) { |
| 264 if (moduleString) { | 225 if (moduleString) { |
| 265 » » moduleString = sftkdb_DupnCat(moduleString," ", 1); | 226 » » moduleString = nssutil_DupnCat(moduleString," ", 1); |
| 266 if (moduleString == NULL) goto loser; | 227 if (moduleString == NULL) goto loser; |
| 267 } | 228 } |
| 268 » moduleString = sftkdb_DupCat(moduleString, line); | 229 » moduleString = nssutil_DupCat(moduleString, line); |
| 269 if (moduleString == NULL) goto loser; | 230 if (moduleString == NULL) goto loser; |
| 270 /* value is already quoted, just write it out */ | 231 /* value is already quoted, just write it out */ |
| 271 } else if (value[1] == '"') { | 232 } else if (value[1] == '"') { |
| 272 if (moduleString) { | 233 if (moduleString) { |
| 273 » » moduleString = sftkdb_DupnCat(moduleString," ", 1); | 234 » » moduleString = nssutil_DupnCat(moduleString," ", 1); |
| 274 if (moduleString == NULL) goto loser; | 235 if (moduleString == NULL) goto loser; |
| 275 } | 236 } |
| 276 » moduleString = sftkdb_DupCat(moduleString, line); | 237 » moduleString = nssutil_DupCat(moduleString, line); |
| 277 if (moduleString == NULL) goto loser; | 238 if (moduleString == NULL) goto loser; |
| 278 /* we have an override parameter section, remember that | 239 /* we have an override parameter section, remember that |
| 279 * we found this (see following comment about why this | 240 * we found this (see following comment about why this |
| 280 * is necessary). */ | 241 * is necessary). */ |
| 281 if (PORT_Strncasecmp(line, "parameters", 10) == 0) { | 242 if (PORT_Strncasecmp(line, "parameters", 10) == 0) { |
| 282 skipParams = PR_TRUE; | 243 skipParams = PR_TRUE; |
| 283 } | 244 } |
| 284 /* | 245 /* |
| 285 * The internal token always overrides it's parameter block | 246 * The internal token always overrides it's parameter block |
| 286 * from the passed in parameters, so wait until then end | 247 * from the passed in parameters, so wait until then end |
| (...skipping 10 matching lines...) Expand all Loading... |
| 297 * the absence of overrides, paramsValue is set to the first | 258 * the absence of overrides, paramsValue is set to the first |
| 298 * parameter block we find. All subsequent blocks are ignored. | 259 * parameter block we find. All subsequent blocks are ignored. |
| 299 * When we find an internal token, the application passed | 260 * When we find an internal token, the application passed |
| 300 * parameters take precident. | 261 * parameters take precident. |
| 301 */ | 262 */ |
| 302 } else if (PORT_Strncasecmp(line, "parameters", 10) == 0) { | 263 } else if (PORT_Strncasecmp(line, "parameters", 10) == 0) { |
| 303 /* already have parameters */ | 264 /* already have parameters */ |
| 304 if (paramsValue) { | 265 if (paramsValue) { |
| 305 continue; | 266 continue; |
| 306 } | 267 } |
| 307 » » paramsValue = sftkdb_quote(&value[1], '"'); | 268 » » paramsValue = NSSUTIL_Quote(&value[1], '"'); |
| 308 if (paramsValue == NULL) goto loser; | 269 if (paramsValue == NULL) goto loser; |
| 309 continue; | 270 continue; |
| 310 } else { | 271 } else { |
| 311 /* may need to quote */ | 272 /* may need to quote */ |
| 312 char *newLine; | 273 char *newLine; |
| 313 if (moduleString) { | 274 if (moduleString) { |
| 314 » » moduleString = sftkdb_DupnCat(moduleString," ", 1); | 275 » » moduleString = nssutil_DupnCat(moduleString," ", 1); |
| 315 if (moduleString == NULL) goto loser; | 276 if (moduleString == NULL) goto loser; |
| 316 } | 277 } |
| 317 » » moduleString = sftkdb_DupnCat(moduleString,line,value-line+1); | 278 » » moduleString = nssutil_DupnCat(moduleString,line,value-line+1); |
| 318 if (moduleString == NULL) goto loser; | 279 if (moduleString == NULL) goto loser; |
| 319 » newLine = sftkdb_quote(&value[1],'"'); | 280 » newLine = NSSUTIL_Quote(&value[1],'"'); |
| 320 if (newLine == NULL) goto loser; | 281 if (newLine == NULL) goto loser; |
| 321 » » moduleString = sftkdb_DupCat(moduleString,newLine); | 282 » » moduleString = nssutil_DupCat(moduleString,newLine); |
| 322 PORT_Free(newLine); | 283 PORT_Free(newLine); |
| 323 if (moduleString == NULL) goto loser; | 284 if (moduleString == NULL) goto loser; |
| 324 } | 285 } |
| 325 | 286 |
| 326 /* check to see if it's internal? */ | 287 /* check to see if it's internal? */ |
| 327 if (PORT_Strncasecmp(line, "NSS=", 4) == 0) { | 288 if (PORT_Strncasecmp(line, "NSS=", 4) == 0) { |
| 328 /* This should be case insensitive! reviewers make | 289 /* This should be case insensitive! reviewers make |
| 329 * me fix it if it's not */ | 290 * me fix it if it's not */ |
| 330 if (PORT_Strstr(line,"internal")) { | 291 if (PORT_Strstr(line,"internal")) { |
| 331 internal = PR_TRUE; | 292 internal = PR_TRUE; |
| 332 /* override the parameters */ | 293 /* override the parameters */ |
| 333 if (paramsValue) { | 294 if (paramsValue) { |
| 334 PORT_Free(paramsValue); | 295 PORT_Free(paramsValue); |
| 335 } | 296 } |
| 336 » » paramsValue = sftkdb_quote(params, '"'); | 297 » » paramsValue = NSSUTIL_Quote(params, '"'); |
| 337 } | 298 } |
| 338 } | 299 } |
| 339 continue; | 300 continue; |
| 340 } | 301 } |
| 341 if ((moduleString == NULL) || (*moduleString == 0)) { | 302 if ((moduleString == NULL) || (*moduleString == 0)) { |
| 342 continue; | 303 continue; |
| 343 } | 304 } |
| 344 | 305 |
| 345 /* | 306 /* |
| 346 * if we are here, we have found a complete stanza. Now write out | 307 * if we are here, we have found a complete stanza. Now write out |
| 347 * any param section we may have found. | 308 * any param section we may have found. |
| 348 */ | 309 */ |
| 349 if (paramsValue) { | 310 if (paramsValue) { |
| 350 /* we had an override */ | 311 /* we had an override */ |
| 351 if (!skipParams) { | 312 if (!skipParams) { |
| 352 » » moduleString = sftkdb_DupnCat(moduleString," parameters=", 12); | 313 » » moduleString = nssutil_DupnCat(moduleString," parameters=", 12); |
| 353 if (moduleString == NULL) goto loser; | 314 if (moduleString == NULL) goto loser; |
| 354 » » moduleString = sftkdb_DupCat(moduleString, paramsValue); | 315 » » moduleString = nssutil_DupCat(moduleString, paramsValue); |
| 355 if (moduleString == NULL) goto loser; | 316 if (moduleString == NULL) goto loser; |
| 356 } | 317 } |
| 357 PORT_Free(paramsValue); | 318 PORT_Free(paramsValue); |
| 358 paramsValue = NULL; | 319 paramsValue = NULL; |
| 359 } | 320 } |
| 360 | 321 |
| 361 if ((moduleCount+1) >= useCount) { | 322 if ((moduleCount+1) >= useCount) { |
| 362 SECStatus rv; | 323 SECStatus rv; |
| 363 » rv = sftkdb_growList(&moduleList, &useCount, moduleCount+1); | 324 » rv = nssutil_growList(&moduleList, &useCount, moduleCount+1); |
| 364 if (rv != SECSuccess) { | 325 if (rv != SECSuccess) { |
| 365 goto loser; | 326 goto loser; |
| 366 } | 327 } |
| 367 } | 328 } |
| 368 | 329 |
| 369 if (internal) { | 330 if (internal) { |
| 370 moduleList[0] = moduleString; | 331 moduleList[0] = moduleString; |
| 371 } else { | 332 } else { |
| 372 moduleList[moduleCount] = moduleString; | 333 moduleList[moduleCount] = moduleString; |
| 373 moduleCount++; | 334 moduleCount++; |
| 374 } | 335 } |
| 375 moduleString = NULL; | 336 moduleString = NULL; |
| 376 internal = PR_FALSE; | 337 internal = PR_FALSE; |
| 377 skipParams = PR_FALSE; | 338 skipParams = PR_FALSE; |
| 378 } | 339 } |
| 379 | 340 |
| 380 if (moduleString) { | 341 if (moduleString) { |
| 381 PORT_Free(moduleString); | 342 PORT_Free(moduleString); |
| 382 moduleString = NULL; | 343 moduleString = NULL; |
| 383 } | 344 } |
| 384 done: | 345 done: |
| 385 /* If we couldn't open a pkcs11 database, look for the old one. | 346 /* if we couldn't open a pkcs11 database, look for the old one */ |
| 386 * This is necessary to maintain the semantics of the transition from | |
| 387 * old to new DB's. If there is an old DB and not new DB, we will | |
| 388 * automatically use the old DB. If the DB was opened read/write, we | |
| 389 * create a new db and upgrade it from the old one. */ | |
| 390 if (fd == NULL) { | 347 if (fd == NULL) { |
| 391 » char *olddbname = sftk_getOldSecmodName(dbname,filename); | 348 » char *olddbname = _NSSUTIL_GetOldSecmodName(dbname,filename); |
| 392 PRStatus status; | 349 PRStatus status; |
| 393 char **oldModuleList; | |
| 394 int i; | |
| 395 | 350 |
| 396 /* couldn't get the old name */ | 351 /* couldn't get the old name */ |
| 397 if (!olddbname) { | 352 if (!olddbname) { |
| 398 goto bail; | 353 goto bail; |
| 399 } | 354 } |
| 400 | 355 |
| 401 /* old one doesn't exist */ | 356 /* old one doesn't exist */ |
| 402 status = PR_Access(olddbname, PR_ACCESS_EXISTS); | 357 status = PR_Access(olddbname, PR_ACCESS_EXISTS); |
| 403 » if (status != PR_SUCCESS) { | 358 » if (status == PR_SUCCESS) { |
| 404 » goto bail; | 359 » PR_smprintf_free(olddbname); |
| 360 » PORT_SetError(SEC_ERROR_LEGACY_DATABASE); |
| 361 » return NULL; |
| 405 } | 362 } |
| 406 | 363 |
| 407 oldModuleList = sftkdbCall_ReadSecmodDB(appName, filename, | |
| 408 olddbname, params, rw); | |
| 409 /* old one had no modules */ | |
| 410 if (!oldModuleList) { | |
| 411 goto bail; | |
| 412 } | |
| 413 | |
| 414 /* count the modules */ | |
| 415 for (i=0; oldModuleList[i]; i++) { } | |
| 416 | |
| 417 /* grow the moduleList if necessary */ | |
| 418 if (i >= useCount) { | |
| 419 SECStatus rv; | |
| 420 rv = sftkdb_growList(&moduleList,&useCount,moduleCount+1); | |
| 421 if (rv != SECSuccess) { | |
| 422 goto loser; | |
| 423 } | |
| 424 } | |
| 425 | |
| 426 /* write each module out, and copy it */ | |
| 427 for (i=0; oldModuleList[i]; i++) { | |
| 428 if (rw) { | |
| 429 sftkdb_AddSecmodDB(dbType,appName,filename,dbname, | |
| 430 oldModuleList[i],rw); | |
| 431 } | |
| 432 if (moduleList[i]) { | |
| 433 PORT_Free(moduleList[i]); | |
| 434 } | |
| 435 moduleList[i] = PORT_Strdup(oldModuleList[i]); | |
| 436 } | |
| 437 | |
| 438 /* done with the old module list */ | |
| 439 sftkdbCall_ReleaseSecmodDBData(appName, filename, olddbname, | |
| 440 oldModuleList, rw); | |
| 441 bail: | 364 bail: |
| 442 if (olddbname) { | 365 if (olddbname) { |
| 443 PR_smprintf_free(olddbname); | 366 PR_smprintf_free(olddbname); |
| 444 } | 367 } |
| 445 } | 368 } |
| 446 | |
| 447 return_default: | |
| 448 | 369 |
| 449 if (!moduleList[0]) { | 370 if (!moduleList[0]) { |
| 450 char * newParams; | 371 char * newParams; |
| 451 » moduleString = PORT_Strdup(SFTK_DEFAULT_INTERNAL_INIT1); | 372 » moduleString = PORT_Strdup(NSSUTIL_DEFAULT_INTERNAL_INIT1); |
| 452 » newParams = sftkdb_quote(params,'"'); | 373 » newParams = NSSUTIL_Quote(params,'"'); |
| 453 if (newParams == NULL) goto loser; | 374 if (newParams == NULL) goto loser; |
| 454 » moduleString = sftkdb_DupCat(moduleString, newParams); | 375 » moduleString = nssutil_DupCat(moduleString, newParams); |
| 455 PORT_Free(newParams); | 376 PORT_Free(newParams); |
| 456 if (moduleString == NULL) goto loser; | 377 if (moduleString == NULL) goto loser; |
| 457 » moduleString = sftkdb_DupCat(moduleString, SFTK_DEFAULT_INTERNAL_INIT2); | 378 » moduleString = nssutil_DupCat(moduleString, |
| 379 » » » » » NSSUTIL_DEFAULT_INTERNAL_INIT2); |
| 458 if (moduleString == NULL) goto loser; | 380 if (moduleString == NULL) goto loser; |
| 459 » moduleString = sftkdb_DupCat(moduleString, SECMOD_SLOT_FLAGS); | 381 » moduleString = nssutil_DupCat(moduleString, |
| 382 » » » » » NSSUTIL_DEFAULT_SFTKN_FLAGS); |
| 460 if (moduleString == NULL) goto loser; | 383 if (moduleString == NULL) goto loser; |
| 461 » moduleString = sftkdb_DupCat(moduleString, SFTK_DEFAULT_INTERNAL_INIT3); | 384 » moduleString = nssutil_DupCat(moduleString, |
| 385 » » » » » NSSUTIL_DEFAULT_INTERNAL_INIT3); |
| 462 if (moduleString == NULL) goto loser; | 386 if (moduleString == NULL) goto loser; |
| 463 moduleList[0] = moduleString; | 387 moduleList[0] = moduleString; |
| 464 moduleString = NULL; | 388 moduleString = NULL; |
| 465 } | 389 } |
| 466 failed = PR_FALSE; | 390 failed = PR_FALSE; |
| 467 | 391 |
| 468 loser: | 392 loser: |
| 469 /* | 393 /* |
| 470 * cleanup | 394 * cleanup |
| 471 */ | 395 */ |
| 472 /* deal with trust cert db here */ | 396 /* deal with trust cert db here */ |
| 473 if (moduleString) { | 397 if (moduleString) { |
| 474 PORT_Free(moduleString); | 398 PORT_Free(moduleString); |
| 475 moduleString = NULL; | 399 moduleString = NULL; |
| 476 } | 400 } |
| 477 if (paramsValue) { | 401 if (paramsValue) { |
| 478 PORT_Free(paramsValue); | 402 PORT_Free(paramsValue); |
| 479 paramsValue = NULL; | 403 paramsValue = NULL; |
| 480 } | 404 } |
| 481 if (failed || (moduleList[0] == NULL)) { | 405 if (failed || (moduleList[0] == NULL)) { |
| 482 /* This is wrong! FIXME */ | 406 /* This is wrong! FIXME */ |
| 483 » sftkdb_releaseSpecList(moduleList); | 407 » nssutil_releaseSpecList(moduleList); |
| 484 moduleList = NULL; | 408 moduleList = NULL; |
| 485 failed = PR_TRUE; | 409 failed = PR_TRUE; |
| 486 } | 410 } |
| 487 if (fd != NULL) { | 411 if (fd != NULL) { |
| 488 fclose(fd); | 412 fclose(fd); |
| 489 } else if (!failed && rw) { | 413 } else if (!failed && rw) { |
| 490 /* update our internal module */ | 414 /* update our internal module */ |
| 491 » sftkdb_AddSecmodDB(dbType,appName,filename,dbname,moduleList[0],rw); | 415 » nssutil_AddSecmodDB(dbType,appName,filename,dbname,moduleList[0],rw); |
| 492 } | 416 } |
| 493 return moduleList; | 417 return moduleList; |
| 494 } | 418 } |
| 495 | 419 |
| 496 SECStatus | 420 static SECStatus |
| 497 sftkdb_ReleaseSecmodDBData(SDBType dbType, const char *appName, | 421 nssutil_ReleaseSecmodDBData(NSSDBType dbType, const char *appName, |
| 498 const char *filename, const char *dbname, | 422 const char *filename, const char *dbname, |
| 499 char **moduleSpecList, PRBool rw) | 423 char **moduleSpecList, PRBool rw) |
| 500 { | 424 { |
| 501 if ((dbname != NULL) && | |
| 502 ((dbType == SDB_LEGACY) || (dbType == SDB_MULTIACCESS))) { | |
| 503 return sftkdbCall_ReleaseSecmodDBData(appName, filename, dbname, | |
| 504 moduleSpecList, rw); | |
| 505 } | |
| 506 if (moduleSpecList) { | 425 if (moduleSpecList) { |
| 507 » sftkdb_releaseSpecList(moduleSpecList); | 426 » nssutil_releaseSpecList(moduleSpecList); |
| 508 } | 427 } |
| 509 return SECSuccess; | 428 return SECSuccess; |
| 510 } | 429 } |
| 511 | 430 |
| 512 | 431 |
| 513 /* | 432 /* |
| 514 * Delete a module from the Data Base | 433 * Delete a module from the Data Base |
| 515 */ | 434 */ |
| 516 SECStatus | 435 static SECStatus |
| 517 sftkdb_DeleteSecmodDB(SDBType dbType, const char *appName, | 436 nssutil_DeleteSecmodDB(NSSDBType dbType, const char *appName, |
| 518 const char *filename, const char *dbname, | 437 const char *filename, const char *dbname, |
| 519 char *args, PRBool rw) | 438 char *args, PRBool rw) |
| 520 { | 439 { |
| 521 /* SHDB_FIXME implement */ | 440 /* SHDB_FIXME implement */ |
| 522 FILE *fd = NULL; | 441 FILE *fd = NULL; |
| 523 FILE *fd2 = NULL; | 442 FILE *fd2 = NULL; |
| 524 char line[MAX_LINE_LENGTH]; | 443 char line[MAX_LINE_LENGTH]; |
| 525 char *dbname2 = NULL; | 444 char *dbname2 = NULL; |
| 526 char *block = NULL; | 445 char *block = NULL; |
| 527 char *name = NULL; | 446 char *name = NULL; |
| 528 char *lib = NULL; | 447 char *lib = NULL; |
| 529 int name_len, lib_len; | 448 int name_len, lib_len; |
| 530 PRBool skip = PR_FALSE; | 449 PRBool skip = PR_FALSE; |
| 531 PRBool found = PR_FALSE; | 450 PRBool found = PR_FALSE; |
| 532 | 451 |
| 533 if (dbname == NULL) { | 452 if (dbname == NULL) { |
| 534 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 453 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
| 535 return SECFailure; | 454 return SECFailure; |
| 536 } | 455 } |
| 537 | 456 |
| 538 if ((dbType == SDB_LEGACY) || (dbType == SDB_MULTIACCESS)) { | |
| 539 return sftkdbCall_DeleteSecmodDB(appName, filename, dbname, args, rw); | |
| 540 } | |
| 541 | |
| 542 if (!rw) { | 457 if (!rw) { |
| 543 PORT_SetError(SEC_ERROR_READ_ONLY); | 458 PORT_SetError(SEC_ERROR_READ_ONLY); |
| 544 return SECFailure; | 459 return SECFailure; |
| 545 } | 460 } |
| 546 | 461 |
| 547 dbname2 = strdup(dbname); | 462 dbname2 = PORT_Strdup(dbname); |
| 548 if (dbname2 == NULL) goto loser; | 463 if (dbname2 == NULL) goto loser; |
| 549 dbname2[strlen(dbname)-1]++; | 464 dbname2[strlen(dbname)-1]++; |
| 550 | 465 |
| 551 /* do we really want to use streams here */ | 466 /* do we really want to use streams here */ |
| 552 fd = fopen(dbname, "r"); | 467 fd = fopen(dbname, "r"); |
| 553 if (fd == NULL) goto loser; | 468 if (fd == NULL) goto loser; |
| 554 #ifdef WINCE | 469 #ifdef WINCE |
| 555 fd2 = fopen(dbname2, "w+"); | 470 fd2 = fopen(dbname2, "w+"); |
| 556 #else | 471 #else |
| 557 fd2 = lfopen(dbname2, "w+", O_CREAT|O_RDWR|O_TRUNC); | 472 fd2 = lfopen(dbname2, "w+", O_CREAT|O_RDWR|O_TRUNC); |
| 558 #endif | 473 #endif |
| 559 if (fd2 == NULL) goto loser; | 474 if (fd2 == NULL) goto loser; |
| 560 | 475 |
| 561 name = sftk_argGetParamValue("name",args); | 476 name = NSSUTIL_ArgGetParamValue("name",args); |
| 562 if (name) { | 477 if (name) { |
| 563 name_len = PORT_Strlen(name); | 478 name_len = PORT_Strlen(name); |
| 564 } | 479 } |
| 565 lib = sftk_argGetParamValue("library",args); | 480 lib = NSSUTIL_ArgGetParamValue("library",args); |
| 566 if (lib) { | 481 if (lib) { |
| 567 lib_len = PORT_Strlen(lib); | 482 lib_len = PORT_Strlen(lib); |
| 568 } | 483 } |
| 569 | 484 |
| 570 | 485 |
| 571 /* | 486 /* |
| 572 * the following loop takes line separated config files and collapses | 487 * the following loop takes line separated config files and collapses |
| 573 * the lines to a single string, escaping and quoting as necessary. | 488 * the lines to a single string, escaping and quoting as necessary. |
| 574 */ | 489 */ |
| 575 /* loop state variables */ | 490 /* loop state variables */ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 592 /* yup, we don't need to save any more data, */ | 507 /* yup, we don't need to save any more data, */ |
| 593 PORT_Free(block); | 508 PORT_Free(block); |
| 594 block=NULL; | 509 block=NULL; |
| 595 /* we don't need to collect more of this block */ | 510 /* we don't need to collect more of this block */ |
| 596 skip = PR_TRUE; | 511 skip = PR_TRUE; |
| 597 /* we don't need to continue searching for the block */ | 512 /* we don't need to continue searching for the block */ |
| 598 found =PR_TRUE; | 513 found =PR_TRUE; |
| 599 continue; | 514 continue; |
| 600 } | 515 } |
| 601 /* not our match, continue to collect data in this block */ | 516 /* not our match, continue to collect data in this block */ |
| 602 » block = sftkdb_DupCat(block,line); | 517 » block = nssutil_DupCat(block,line); |
| 603 continue; | 518 continue; |
| 604 } | 519 } |
| 605 /* we've collected a block of data that wasn't the module we were | 520 /* we've collected a block of data that wasn't the module we were |
| 606 * looking for, write it out */ | 521 * looking for, write it out */ |
| 607 if (block) { | 522 if (block) { |
| 608 fwrite(block, PORT_Strlen(block), 1, fd2); | 523 fwrite(block, PORT_Strlen(block), 1, fd2); |
| 609 PORT_Free(block); | 524 PORT_Free(block); |
| 610 block = NULL; | 525 block = NULL; |
| 611 } | 526 } |
| 612 /* If we didn't just delete the this block, keep the blank line */ | 527 /* If we didn't just delete the this block, keep the blank line */ |
| (...skipping 30 matching lines...) Expand all Loading... |
| 643 PORT_Free(dbname2); | 558 PORT_Free(dbname2); |
| 644 } | 559 } |
| 645 PORT_Free(lib); | 560 PORT_Free(lib); |
| 646 PORT_Free(name); | 561 PORT_Free(name); |
| 647 return SECFailure; | 562 return SECFailure; |
| 648 } | 563 } |
| 649 | 564 |
| 650 /* | 565 /* |
| 651 * Add a module to the Data base | 566 * Add a module to the Data base |
| 652 */ | 567 */ |
| 653 SECStatus | 568 static SECStatus |
| 654 sftkdb_AddSecmodDB(SDBType dbType, const char *appName, | 569 nssutil_AddSecmodDB(NSSDBType dbType, const char *appName, |
| 655 const char *filename, const char *dbname, | 570 const char *filename, const char *dbname, |
| 656 char *module, PRBool rw) | 571 char *module, PRBool rw) |
| 657 { | 572 { |
| 658 FILE *fd = NULL; | 573 FILE *fd = NULL; |
| 659 char *block = NULL; | 574 char *block = NULL; |
| 660 PRBool libFound = PR_FALSE; | 575 PRBool libFound = PR_FALSE; |
| 661 | 576 |
| 662 if (dbname == NULL) { | 577 if (dbname == NULL) { |
| 663 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 578 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
| 664 return SECFailure; | 579 return SECFailure; |
| 665 } | 580 } |
| 666 | 581 |
| 667 if ((dbType == SDB_LEGACY) || (dbType == SDB_MULTIACCESS)) { | |
| 668 return sftkdbCall_AddSecmodDB(appName, filename, dbname, module, rw); | |
| 669 } | |
| 670 | |
| 671 /* can't write to a read only module */ | 582 /* can't write to a read only module */ |
| 672 if (!rw) { | 583 if (!rw) { |
| 673 PORT_SetError(SEC_ERROR_READ_ONLY); | 584 PORT_SetError(SEC_ERROR_READ_ONLY); |
| 674 return SECFailure; | 585 return SECFailure; |
| 675 } | 586 } |
| 676 | 587 |
| 677 /* remove the previous version if it exists */ | 588 /* remove the previous version if it exists */ |
| 678 (void) sftkdb_DeleteSecmodDB(dbType, appName, filename, dbname, module, rw); | 589 (void) nssutil_DeleteSecmodDB(dbType, appName, filename, |
| 590 » » » » dbname, module, rw); |
| 679 | 591 |
| 680 #ifdef WINCE | 592 #ifdef WINCE |
| 681 fd = fopen(dbname, "a+"); | 593 fd = fopen(dbname, "a+"); |
| 682 #else | 594 #else |
| 683 fd = lfopen(dbname, "a+", O_CREAT|O_RDWR|O_APPEND); | 595 fd = lfopen(dbname, "a+", O_CREAT|O_RDWR|O_APPEND); |
| 684 #endif | 596 #endif |
| 685 if (fd == NULL) { | 597 if (fd == NULL) { |
| 686 return SECFailure; | 598 return SECFailure; |
| 687 } | 599 } |
| 688 module = sftk_argStrip(module); | 600 module = NSSUTIL_ArgStrip(module); |
| 689 while (*module) { | 601 while (*module) { |
| 690 int count; | 602 int count; |
| 691 char *keyEnd = PORT_Strchr(module,'='); | 603 char *keyEnd = PORT_Strchr(module,'='); |
| 692 char *value; | 604 char *value; |
| 693 | 605 |
| 694 if (PORT_Strncmp(module, "library=", 8) == 0) { | 606 if (PORT_Strncmp(module, "library=", 8) == 0) { |
| 695 libFound=PR_TRUE; | 607 libFound=PR_TRUE; |
| 696 } | 608 } |
| 697 if (keyEnd == NULL) { | 609 if (keyEnd == NULL) { |
| 698 » block = sftkdb_DupCat(block, module); | 610 » block = nssutil_DupCat(block, module); |
| 699 break; | 611 break; |
| 700 } | 612 } |
| 701 » block = sftkdb_DupnCat(block, module, keyEnd-module+1); | 613 » block = nssutil_DupnCat(block, module, keyEnd-module+1); |
| 702 if (block == NULL) { goto loser; } | 614 if (block == NULL) { goto loser; } |
| 703 » value = sftk_argFetchValue(&keyEnd[1], &count); | 615 » value = NSSUTIL_ArgFetchValue(&keyEnd[1], &count); |
| 704 if (value) { | 616 if (value) { |
| 705 » block = sftkdb_DupCat(block, sftk_argStrip(value)); | 617 » block = nssutil_DupCat(block, NSSUTIL_ArgStrip(value)); |
| 706 PORT_Free(value); | 618 PORT_Free(value); |
| 707 } | 619 } |
| 708 if (block == NULL) { goto loser; } | 620 if (block == NULL) { goto loser; } |
| 709 » block = sftkdb_DupnCat(block, "\n", 1); | 621 » block = nssutil_DupnCat(block, "\n", 1); |
| 710 module = keyEnd + 1 + count; | 622 module = keyEnd + 1 + count; |
| 711 » module = sftk_argStrip(module); | 623 » module = NSSUTIL_ArgStrip(module); |
| 712 } | 624 } |
| 713 if (block) { | 625 if (block) { |
| 714 if (!libFound) { | 626 if (!libFound) { |
| 715 fprintf(fd,"library=\n"); | 627 fprintf(fd,"library=\n"); |
| 716 } | 628 } |
| 717 fwrite(block, PORT_Strlen(block), 1, fd); | 629 fwrite(block, PORT_Strlen(block), 1, fd); |
| 718 fprintf(fd,"\n"); | 630 fprintf(fd,"\n"); |
| 719 PORT_Free(block); | 631 PORT_Free(block); |
| 720 block = NULL; | 632 block = NULL; |
| 721 } | 633 } |
| 722 fclose(fd); | 634 fclose(fd); |
| 723 return SECSuccess; | 635 return SECSuccess; |
| 724 | 636 |
| 725 loser: | 637 loser: |
| 726 PORT_Free(block); | 638 PORT_Free(block); |
| 727 fclose(fd); | 639 fclose(fd); |
| 728 return SECFailure; | 640 return SECFailure; |
| 729 } | 641 } |
| 730 | 642 |
| 731 | 643 |
| 644 char ** |
| 645 NSSUTIL_DoModuleDBFunction(unsigned long function,char *parameters, void *args) |
| 646 { |
| 647 char *secmod = NULL; |
| 648 char *appName = NULL; |
| 649 char *filename = NULL; |
| 650 NSSDBType dbType = NSS_DB_TYPE_NONE; |
| 651 PRBool rw; |
| 652 static char *success="Success"; |
| 653 char **rvstr = NULL; |
| 654 |
| 655 |
| 656 secmod = _NSSUTIL_GetSecmodName(parameters, &dbType, &appName, |
| 657 &filename, &rw); |
| 658 if ((dbType == NSS_DB_TYPE_LEGACY) || |
| 659 (dbType == NSS_DB_TYPE_MULTIACCESS)) { |
| 660 /* we can't handle the old database, only softoken can */ |
| 661 PORT_SetError(SEC_ERROR_LEGACY_DATABASE); |
| 662 rvstr = NULL; |
| 663 goto done; |
| 664 } |
| 665 |
| 666 switch (function) { |
| 667 case SECMOD_MODULE_DB_FUNCTION_FIND: |
| 668 rvstr = nssutil_ReadSecmodDB(dbType,appName,filename, |
| 669 secmod,(char *)parameters,rw); |
| 670 break; |
| 671 case SECMOD_MODULE_DB_FUNCTION_ADD: |
| 672 rvstr = (nssutil_AddSecmodDB(dbType,appName,filename, |
| 673 secmod,(char *)args,rw) == SECSuccess) ? &success: NULL; |
| 674 break; |
| 675 case SECMOD_MODULE_DB_FUNCTION_DEL: |
| 676 rvstr = (nssutil_DeleteSecmodDB(dbType,appName,filename, |
| 677 secmod,(char *)args,rw) == SECSuccess) ? &success: NULL; |
| 678 break; |
| 679 case SECMOD_MODULE_DB_FUNCTION_RELEASE: |
| 680 rvstr = (nssutil_ReleaseSecmodDBData(dbType, appName,filename, |
| 681 secmod, (char **)args,rw) == SECSuccess) ? &success: NULL; |
| 682 break; |
| 683 } |
| 684 done: |
| 685 if (secmod) PR_smprintf_free(secmod); |
| 686 if (appName) PORT_Free(appName); |
| 687 if (filename) PORT_Free(filename); |
| 688 return rvstr; |
| 689 } |
| OLD | NEW |