Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: mozilla/security/nss/lib/pk11wrap/pk11util.c

Issue 10961060: Update NSS to NSS 3.14 Beta 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Merge nss-static2.patch into nss-static.patch Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 * Initialize the PCKS 11 subsystem 5 * Initialize the PCKS 11 subsystem
6 */ 6 */
7 #include "seccomon.h" 7 #include "seccomon.h"
8 #include "secmod.h" 8 #include "secmod.h"
9 #include "nssilock.h" 9 #include "nssilock.h"
10 #include "secmodi.h" 10 #include "secmodi.h"
11 #include "secmodti.h" 11 #include "secmodti.h"
12 #include "pk11func.h" 12 #include "pk11func.h"
13 #include "pki3hack.h" 13 #include "pki3hack.h"
14 #include "secerr.h" 14 #include "secerr.h"
15 #include "dev.h" 15 #include "dev.h"
16 #include "pkcs11ni.h" 16 #include "pkcs11ni.h"
17 #include "utilpars.h"
17 18
18 /* these are for displaying error messages */ 19 /* these are for displaying error messages */
19 20
20 static SECMODModuleList *modules = NULL; 21 static SECMODModuleList *modules = NULL;
21 static SECMODModuleList *modulesDB = NULL; 22 static SECMODModuleList *modulesDB = NULL;
22 static SECMODModuleList *modulesUnload = NULL; 23 static SECMODModuleList *modulesUnload = NULL;
23 static SECMODModule *internalModule = NULL; 24 static SECMODModule *internalModule = NULL;
24 static SECMODModule *defaultDBModule = NULL; 25 static SECMODModule *defaultDBModule = NULL;
25 static SECMODModule *pendingModule = NULL; 26 static SECMODModule *pendingModule = NULL;
26 static SECMODListLock *moduleLock = NULL; 27 static SECMODListLock *moduleLock = NULL;
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 slot->flagSeries = series; 1076 slot->flagSeries = series;
1076 SECMOD_ReleaseReadLock(moduleLock); 1077 SECMOD_ReleaseReadLock(moduleLock);
1077 PZ_Lock(mod->refLock); 1078 PZ_Lock(mod->refLock);
1078 mod->evControlMask &= ~SECMOD_END_WAIT; 1079 mod->evControlMask &= ~SECMOD_END_WAIT;
1079 PZ_Unlock(mod->refLock); 1080 PZ_Unlock(mod->refLock);
1080 return PK11_ReferenceSlot(slot); 1081 return PK11_ReferenceSlot(slot);
1081 } 1082 }
1082 } 1083 }
1083 SECMOD_ReleaseReadLock(moduleLock); 1084 SECMOD_ReleaseReadLock(moduleLock);
1084 /* if everything was perm modules, don't lock up forever */ 1085 /* if everything was perm modules, don't lock up forever */
1085 » if (!removableSlotsFound) { 1086 » if ((mod->slotCount !=0) && !removableSlotsFound) {
1086 error =SEC_ERROR_NO_SLOT_SELECTED; 1087 error =SEC_ERROR_NO_SLOT_SELECTED;
1087 PZ_Lock(mod->refLock); 1088 PZ_Lock(mod->refLock);
1088 break; 1089 break;
1089 } 1090 }
1090 if (flags & CKF_DONT_BLOCK) { 1091 if (flags & CKF_DONT_BLOCK) {
1091 PZ_Lock(mod->refLock); 1092 PZ_Lock(mod->refLock);
1092 break; 1093 break;
1093 } 1094 }
1094 PR_Sleep(latency); 1095 PR_Sleep(latency);
1095 PZ_Lock(mod->refLock); 1096 PZ_Lock(mod->refLock);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 SECMOD_GetReadLock(moduleLock); 1245 SECMOD_GetReadLock(moduleLock);
1245 for (i=0; i < mod->slotCount; i++) { 1246 for (i=0; i < mod->slotCount; i++) {
1246 PK11SlotInfo *slot = mod->slots[i]; 1247 PK11SlotInfo *slot = mod->slots[i];
1247 /* perm modules are not inserted or removed */ 1248 /* perm modules are not inserted or removed */
1248 if (slot->isPerm) { 1249 if (slot->isPerm) {
1249 continue; 1250 continue;
1250 } 1251 }
1251 ret = PR_TRUE; 1252 ret = PR_TRUE;
1252 break; 1253 break;
1253 } 1254 }
1255 if (mod->slotCount == 0 ) {
1256 ret = PR_TRUE;
1257 }
1254 SECMOD_ReleaseReadLock(moduleLock); 1258 SECMOD_ReleaseReadLock(moduleLock);
1255 return ret; 1259 return ret;
1256 } 1260 }
1257 1261
1258 /* 1262 /*
1259 * helper function to actually create and destroy user defined slots 1263 * helper function to actually create and destroy user defined slots
1260 */ 1264 */
1261 static SECStatus 1265 static SECStatus
1262 secmod_UserDBOp(PK11SlotInfo *slot, CK_OBJECT_CLASS objClass, 1266 secmod_UserDBOp(PK11SlotInfo *slot, CK_OBJECT_CLASS objClass,
1263 const char *sendSpec) 1267 const char *sendSpec)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 return NULL; 1365 return NULL;
1362 } 1366 }
1363 1367
1364 /* just grab the first slot in the module, any present slot should work */ 1368 /* just grab the first slot in the module, any present slot should work */
1365 slot = PK11_ReferenceSlot(mod->slots[0]); 1369 slot = PK11_ReferenceSlot(mod->slots[0]);
1366 if (slot == NULL) { 1370 if (slot == NULL) {
1367 return NULL; 1371 return NULL;
1368 } 1372 }
1369 1373
1370 /* we've found the slot, now build the moduleSpec */ 1374 /* we've found the slot, now build the moduleSpec */
1371 escSpec = secmod_DoubleEscape(moduleSpec, '>', ']'); 1375 escSpec = NSSUTIL_DoubleEscape(moduleSpec, '>', ']');
1372 if (escSpec == NULL) { 1376 if (escSpec == NULL) {
1373 PK11_FreeSlot(slot); 1377 PK11_FreeSlot(slot);
1374 return NULL; 1378 return NULL;
1375 } 1379 }
1376 sendSpec = PR_smprintf("tokens=[0x%x=<%s>]", slotID, escSpec); 1380 sendSpec = PR_smprintf("tokens=[0x%x=<%s>]", slotID, escSpec);
1377 PORT_Free(escSpec); 1381 PORT_Free(escSpec);
1378 1382
1379 if (sendSpec == NULL) { 1383 if (sendSpec == NULL) {
1380 /* PR_smprintf does not set SEC_ERROR_NO_MEMORY on failure. */ 1384 /* PR_smprintf does not set SEC_ERROR_NO_MEMORY on failure. */
1381 PK11_FreeSlot(slot); 1385 PK11_FreeSlot(slot);
1382 PORT_SetError(SEC_ERROR_NO_MEMORY); 1386 PORT_SetError(SEC_ERROR_NO_MEMORY);
1383 return NULL; 1387 return NULL;
1384 } 1388 }
1385 rv = secmod_UserDBOp(slot, CKO_NETSCAPE_NEWSLOT, sendSpec); 1389 rv = secmod_UserDBOp(slot, CKO_NETSCAPE_NEWSLOT, sendSpec);
1386 PR_smprintf_free(sendSpec); 1390 PR_smprintf_free(sendSpec);
1387 PK11_FreeSlot(slot); 1391 PK11_FreeSlot(slot);
1388 if (rv != SECSuccess) { 1392 if (rv != SECSuccess) {
1389 return NULL; 1393 return NULL;
1390 } 1394 }
1391 1395
1392 return SECMOD_FindSlotByID(mod, slotID); 1396 slot = SECMOD_FindSlotByID(mod, slotID);
1397 if (slot) {
1398 » /* if we are in the delay period for the "isPresent" call, reset
1399 » * the delay since we know things have probably changed... */
1400 » if (slot->nssToken && slot->nssToken->slot) {
1401 » nssSlot_ResetDelay(slot->nssToken->slot);
1402 » }
1403 » /* force the slot info structures to properly reset */
1404 » (void)PK11_IsPresent(slot);
1405 }
1406 return slot;
1393 } 1407 }
1394 1408
1395 /* 1409 /*
1396 * Open a new database using the softoken. The caller is responsible for making 1410 * Open a new database using the softoken. The caller is responsible for making
1397 * sure the module spec is correct and usable. The caller should ask for one 1411 * sure the module spec is correct and usable. The caller should ask for one
1398 * new database per call if the caller wants to get meaningful information 1412 * new database per call if the caller wants to get meaningful information
1399 * about the new database. 1413 * about the new database.
1400 * 1414 *
1401 * moduleSpec is the same data that you would pass to softoken at 1415 * moduleSpec is the same data that you would pass to softoken at
1402 * initialization time under the 'tokens' options. For example, if you were 1416 * initialization time under the 'tokens' options. For example, if you were
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 * on multiple failures, we are only returning the lastError. The caller 1570 * on multiple failures, we are only returning the lastError. The caller
1557 * can determine which slots are bad by calling PK11_IsDisabled(). 1571 * can determine which slots are bad by calling PK11_IsDisabled().
1558 */ 1572 */
1559 if (rrv != SECSuccess) { 1573 if (rrv != SECSuccess) {
1560 /* restore the last error code */ 1574 /* restore the last error code */
1561 PORT_SetError(lastError); 1575 PORT_SetError(lastError);
1562 } 1576 }
1563 1577
1564 return rrv; 1578 return rrv;
1565 } 1579 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698