Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

1.3 KB
Raw Blame
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char **argv) {
    if (argc != 2) return 1;
    if (SecKeychainSetUserInteractionAllowed(false) != errSecSuccess) return 4;
    SecKeychainRef keychain = NULL;
    OSStatus status = SecKeychainOpen(argv[1], &keychain);
    if (status != errSecSuccess) return 2;
    const char *service = "com.dbx.tests.development-signing";
    const char *account = "fixture";
    const char *expected = "fixture-only-value";
    UInt32 length = 0;
    void *password = NULL;
    status = SecKeychainFindGenericPassword(keychain, (UInt32)strlen(service), service,
        (UInt32)strlen(account), account, &length, &password, NULL);
    if (status == errSecItemNotFound) {
        status = SecKeychainAddGenericPassword(keychain, (UInt32)strlen(service), service,
            (UInt32)strlen(account), account, (UInt32)strlen(expected), expected, NULL);
    } else if (status == errSecSuccess) {
        if (length != strlen(expected) || memcmp(password, expected, length) != 0) status = errSecDecode;
        SecKeychainItemFreeContent(NULL, password);
    }
    CFRelease(keychain);
    printf("build=%d status=%d\n", DBX_PROBE_VERSION, (int)status);
    return status == errSecSuccess ? 0 : 3;
}