예제 #1
0
int
static test7(CSSM_DL_HANDLE dl)
{
    int pass = 1;
    CSSM_DL_DB_HANDLE dldb = { dl };

    /* Case 7 non autocommit create delete rollback then close. */
    pass &= ok_status(CSSM_DL_DbCreate(dldb.DLHandle, DBNAME,
                                       NULL /* DbLocation */,
                                       &dbInfo,
                                       CSSM_DB_ACCESS_READ | CSSM_DB_ACCESS_WRITE,
                                       NULL /* CredAndAclEntry */,
                                       &openParameters,
                                       &dldb.DBHandle),
                      "CSSM_DL_DbCreate");

    pass &= ok_status(CSSM_DL_DbDelete(dldb.DLHandle, DBNAME,
                                       NULL /* DbLocation */, NULL /* AccessCred */), "CSSM_DL_DbDelete");
    pass &= ok_status(CSSM_DL_PassThrough(dldb, CSSM_APPLEFILEDL_ROLLBACK,
                                          NULL, NULL), "CSSM_APPLEFILEDL_ROLLBACK");
    pass &= ok_status(CSSM_DL_DbClose(dldb), "CSSM_DL_DbClose");
    pass &= is_unix(unlink(DBNAME), ENOENT, "unlink");

    return pass;
}
/*
 * open a DB, ensure it's empty.
 */
CSSM_DB_HANDLE cuDbStartup(
	CSSM_DL_HANDLE		dlHand,			// from dlStartup()
	const char 			*dbName)
{
	CSSM_DB_HANDLE				dbHand = 0;
	CSSM_RETURN					crtn;
	CSSM_DBINFO					dbInfo;
	
	/* first delete possible existing DB, ignore error */
	crtn = CSSM_DL_DbDelete(dlHand, dbName, NULL, NULL);
	switch(crtn) {
		/* only allowed error is "no such file" */
		case CSSM_OK:
		case CSSMERR_DL_DATASTORE_DOESNOT_EXIST:
			break;
		default:
			cuPrintError("CSSM_DL_DbDelete", crtn);
			return 0;
	}
	
	memset(&dbInfo, 0, sizeof(CSSM_DBINFO));
	
	/* now create it */
	crtn = CSSM_DL_DbCreate(dlHand, 
		dbName,
		NULL,						// DbLocation
		&dbInfo,
		// &Security::KeychainCore::Schema::DBInfo,
		CSSM_DB_ACCESS_PRIVILEGED,
		NULL,						// CredAndAclEntry
		NULL,						// OpenParameters
		&dbHand);
	if(crtn) {
		cuPrintError("CSSM_DL_DbCreate", crtn);
	}
	return dbHand;
}
예제 #3
0
int
static test2(CSSM_DL_HANDLE dl)
{
    int pass = 1;
    CSSM_DL_DB_HANDLE dldb = { dl };

    /* Case 2 regular create delete then close. */
    pass &= ok_status(CSSM_DL_DbCreate(dldb.DLHandle, DBNAME,
                                       NULL /* DbLocation */,
                                       &dbInfo,
                                       CSSM_DB_ACCESS_READ | CSSM_DB_ACCESS_WRITE,
                                       NULL /* CredAndAclEntry */,
                                       NULL /* &openParameters */,
                                       &dldb.DBHandle),
                      "CSSM_DL_DbCreate");

    pass &= ok_status(CSSM_DL_DbDelete(dldb.DLHandle, DBNAME,
                                       NULL /* DbLocation */,
                                       NULL /* AccessCred */), "CSSM_DL_DbDelete");
    pass &= ok_status(CSSM_DL_DbClose(dldb), "CSSM_DL_DbClose");
    pass &= is_unix(unlink(DBNAME), ENOENT, "unlink");

    return pass;
}