当前位置: 首页 > 工具软件 > open-keychain > 使用案例 >

清理keyChain

刁俊人
2023-12-01

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);

}


 类似资料: