| 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 each key database and one for each cert | 10 * There is one SFTKDBHandle for each key database and one for each cert |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } else { | 158 } else { |
| 159 file = PR_smprintf("%s", filename); | 159 file = PR_smprintf("%s", filename); |
| 160 } | 160 } |
| 161 PORT_Free(dirPath); | 161 PORT_Free(dirPath); |
| 162 return file; | 162 return file; |
| 163 } | 163 } |
| 164 | 164 |
| 165 static SECStatus nssutil_AddSecmodDBEntry(const char *appName, | 165 static SECStatus nssutil_AddSecmodDBEntry(const char *appName, |
| 166 const char *filename, | 166 const char *filename, |
| 167 const char *dbname, | 167 const char *dbname, |
| 168 char *module, PRBool rw); | 168 const char *module, PRBool rw); |
| 169 | 169 |
| 170 enum lfopen_mode { lfopen_truncate, lfopen_append }; | 170 enum lfopen_mode { lfopen_truncate, lfopen_append }; |
| 171 | 171 |
| 172 FILE * | 172 FILE * |
| 173 lfopen(const char *name, enum lfopen_mode om, os_open_permissions_type open_perm
s) | 173 lfopen(const char *name, enum lfopen_mode om, os_open_permissions_type open_perm
s) |
| 174 { | 174 { |
| 175 int fd; | 175 int fd; |
| 176 FILE *file; | 176 FILE *file; |
| 177 | 177 |
| 178 fd = os_open(name, | 178 fd = os_open(name, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 203 char **moduleList = NULL; | 203 char **moduleList = NULL; |
| 204 int moduleCount = 1; | 204 int moduleCount = 1; |
| 205 int useCount = SECMOD_STEP; | 205 int useCount = SECMOD_STEP; |
| 206 char line[MAX_LINE_LENGTH]; | 206 char line[MAX_LINE_LENGTH]; |
| 207 PRBool internal = PR_FALSE; | 207 PRBool internal = PR_FALSE; |
| 208 PRBool skipParams = PR_FALSE; | 208 PRBool skipParams = PR_FALSE; |
| 209 char *moduleString = NULL; | 209 char *moduleString = NULL; |
| 210 char *paramsValue=NULL; | 210 char *paramsValue=NULL; |
| 211 PRBool failed = PR_TRUE; | 211 PRBool failed = PR_TRUE; |
| 212 | 212 |
| 213 moduleList = (char **) PORT_ZAlloc(useCount*sizeof(char **)); | 213 moduleList = (char **) PORT_ZAlloc(useCount*sizeof(char *)); |
| 214 if (moduleList == NULL) return NULL; | 214 if (moduleList == NULL) return NULL; |
| 215 | 215 |
| 216 if (dbname == NULL) { | 216 if (dbname == NULL) { |
| 217 goto return_default; | 217 goto return_default; |
| 218 } | 218 } |
| 219 | 219 |
| 220 /* do we really want to use streams here */ | 220 /* do we really want to use streams here */ |
| 221 fd = fopen(dbname, "r"); | 221 fd = fopen(dbname, "r"); |
| 222 if (fd == NULL) goto done; | 222 if (fd == NULL) goto done; |
| 223 | 223 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 380 |
| 381 /* couldn't get the old name */ | 381 /* couldn't get the old name */ |
| 382 if (!olddbname) { | 382 if (!olddbname) { |
| 383 goto bail; | 383 goto bail; |
| 384 } | 384 } |
| 385 | 385 |
| 386 /* old one exists */ | 386 /* old one exists */ |
| 387 status = PR_Access(olddbname, PR_ACCESS_EXISTS); | 387 status = PR_Access(olddbname, PR_ACCESS_EXISTS); |
| 388 if (status == PR_SUCCESS) { | 388 if (status == PR_SUCCESS) { |
| 389 PR_smprintf_free(olddbname); | 389 PR_smprintf_free(olddbname); |
| 390 » PORT_ZFree(moduleList, useCount*sizeof(char **)); | 390 » PORT_ZFree(moduleList, useCount*sizeof(char *)); |
| 391 PORT_SetError(SEC_ERROR_LEGACY_DATABASE); | 391 PORT_SetError(SEC_ERROR_LEGACY_DATABASE); |
| 392 return NULL; | 392 return NULL; |
| 393 } | 393 } |
| 394 | 394 |
| 395 bail: | 395 bail: |
| 396 if (olddbname) { | 396 if (olddbname) { |
| 397 PR_smprintf_free(olddbname); | 397 PR_smprintf_free(olddbname); |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 } | 462 } |
| 463 | 463 |
| 464 | 464 |
| 465 /* | 465 /* |
| 466 * Delete a module from the Data Base | 466 * Delete a module from the Data Base |
| 467 */ | 467 */ |
| 468 static SECStatus | 468 static SECStatus |
| 469 nssutil_DeleteSecmodDBEntry(const char *appName, | 469 nssutil_DeleteSecmodDBEntry(const char *appName, |
| 470 const char *filename, | 470 const char *filename, |
| 471 const char *dbname, | 471 const char *dbname, |
| 472 char *args, | 472 const char *args, |
| 473 PRBool rw) | 473 PRBool rw) |
| 474 { | 474 { |
| 475 /* SHDB_FIXME implement */ | 475 /* SHDB_FIXME implement */ |
| 476 os_stat_type stat_existing; | 476 os_stat_type stat_existing; |
| 477 os_open_permissions_type file_mode; | 477 os_open_permissions_type file_mode; |
| 478 FILE *fd = NULL; | 478 FILE *fd = NULL; |
| 479 FILE *fd2 = NULL; | 479 FILE *fd2 = NULL; |
| 480 char line[MAX_LINE_LENGTH]; | 480 char line[MAX_LINE_LENGTH]; |
| 481 char *dbname2 = NULL; | 481 char *dbname2 = NULL; |
| 482 char *block = NULL; | 482 char *block = NULL; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 PORT_Free(name); | 603 PORT_Free(name); |
| 604 return SECFailure; | 604 return SECFailure; |
| 605 } | 605 } |
| 606 | 606 |
| 607 /* | 607 /* |
| 608 * Add a module to the Data base | 608 * Add a module to the Data base |
| 609 */ | 609 */ |
| 610 static SECStatus | 610 static SECStatus |
| 611 nssutil_AddSecmodDBEntry(const char *appName, | 611 nssutil_AddSecmodDBEntry(const char *appName, |
| 612 const char *filename, const char *dbname, | 612 const char *filename, const char *dbname, |
| 613 char *module, PRBool rw) | 613 const char *module, PRBool rw) |
| 614 { | 614 { |
| 615 os_stat_type stat_existing; | 615 os_stat_type stat_existing; |
| 616 os_open_permissions_type file_mode; | 616 os_open_permissions_type file_mode; |
| 617 FILE *fd = NULL; | 617 FILE *fd = NULL; |
| 618 char *block = NULL; | 618 char *block = NULL; |
| 619 PRBool libFound = PR_FALSE; | 619 PRBool libFound = PR_FALSE; |
| 620 | 620 |
| 621 if (dbname == NULL) { | 621 if (dbname == NULL) { |
| 622 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 622 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
| 623 return SECFailure; | 623 return SECFailure; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 secmod, (char **)args, rw) | 729 secmod, (char **)args, rw) |
| 730 == SECSuccess) ? &success: NULL; | 730 == SECSuccess) ? &success: NULL; |
| 731 break; | 731 break; |
| 732 } | 732 } |
| 733 done: | 733 done: |
| 734 if (secmod) PR_smprintf_free(secmod); | 734 if (secmod) PR_smprintf_free(secmod); |
| 735 if (appName) PORT_Free(appName); | 735 if (appName) PORT_Free(appName); |
| 736 if (filename) PORT_Free(filename); | 736 if (filename) PORT_Free(filename); |
| 737 return rvstr; | 737 return rvstr; |
| 738 } | 738 } |
| OLD | NEW |