清理keyChain

sqlite3 *database;

int openResult = sqlite3_open("/var/Keychains/keychain-2.db", &database);

if (openResult == SQLITE_OK)

{

    int execResult = sqlite3_exec(database, "DELETE FROM genp WHERE agrp <> 'apple'", NULL, NULL, NULL);

    if (execResult != SQLITE_OK) NSLog(@"Failed to exec DELETE FROM genp WHERE agrp <> 'apple', error %d", execResult);

    

    execResult = sqlite3_exec(database, "DELETE FROM cert WHERE agrp <> 'lockdown-identities'", NULL, NULL, NULL);

    if (execResult != SQLITE_OK) NSLog(@"Failed to exec DELETE FROM cert WHERE agrp <> 'lockdown-identities', error %d", execResult);

    

    execResult = sqlite3_exec(database, "DELETE FROM keys WHERE agrp <> 'lockdown-identities'", NULL, NULL, NULL);

    if (execResult != SQLITE_OK) NSLog(@"Failed to exec DELETE FROM keys WHERE agrp <> 'lockdown-identities'', error %d", execResult);

    

    execResult = sqlite3_exec(database, "DELETE FROM inet", NULL, NULL, NULL);

    if (execResult != SQLITE_OK) NSLog(@"Failed to exec DELETE FROM inet, error %d", execResult);

    

    execResult = sqlite3_exec(database, "DELETE FROM sqlite_sequence", NULL, NULL, NULL);

    if (execResult != SQLITE_OK) NSLog(@"Failed to exec DELETE FROM sqlite_sequence, error %d", execResult);

    

    sqlite3_close(database);

}


你可能感兴趣的:(清理keyChain)