From b47874f304894464ff72fbc1d235153ccb8f7b22 Mon Sep 17 00:00:00 2001 From: Craig Morten <124147726+jlp-craigmorten@users.noreply.github.com> Date: Thu, 1 Feb 2024 11:51:50 +0000 Subject: [PATCH] fix: sonoma expects extra values in tcc.db (#28) * fix: sonoma expects extra values in tcc.db * fix: wrong version number for Sonoma --- .github/workflows/test.yml | 2 +- src/macOS/updateTccDb.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73f569b..f1fde4c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-11, macos-12, macos-13, windows-2019, windows-2022] + os: [macos-11, macos-12, macos-13, macos-14, windows-2019, windows-2022] steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 diff --git a/src/macOS/updateTccDb.ts b/src/macOS/updateTccDb.ts index 0d99bd9..5588bb4 100644 --- a/src/macOS/updateTccDb.ts +++ b/src/macOS/updateTccDb.ts @@ -1,3 +1,4 @@ +import { release } from "os"; import { execSync } from "child_process"; import { ERR_MACOS_UNABLE_TO_WRITE_USER_TCC_DB } from "../errors"; @@ -206,12 +207,17 @@ const getEntries = (): string[] => { ]; }; -export const USER_PATH = "$HOME/Library/Application Support/com.apple.TCC/TCC.db"; +export const USER_PATH = + "$HOME/Library/Application Support/com.apple.TCC/TCC.db"; export const SYSTEM_PATH = "/Library/Application Support/com.apple.TCC/TCC.db"; export function updateTccDb(path: string): void { for (const values of getEntries()) { - const query = `INSERT OR IGNORE INTO access VALUES(${values});`; + const osRelease = release(); + const isSonomaOrNewer = parseInt(osRelease.split(".").at(0)) >= 23; + const query = `INSERT OR IGNORE INTO access VALUES(${values}${ + isSonomaOrNewer ? `,NULL,NULL,'UNUSED',${epoch}` : "" + });`; try { execSync(`sqlite3 "${path}" "${query}" >/dev/null 2>&1`);