Skip to content

Commit b47874f

Browse files
fix: sonoma expects extra values in tcc.db (#28)
* fix: sonoma expects extra values in tcc.db * fix: wrong version number for Sonoma
1 parent f62278d commit b47874f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ${{ matrix.os }}
1414
strategy:
1515
matrix:
16-
os: [macos-11, macos-12, macos-13, windows-2019, windows-2022]
16+
os: [macos-11, macos-12, macos-13, macos-14, windows-2019, windows-2022]
1717
steps:
1818
- uses: actions/checkout@v3
1919
- uses: actions/setup-node@v3

src/macOS/updateTccDb.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { release } from "os";
12
import { execSync } from "child_process";
23
import { ERR_MACOS_UNABLE_TO_WRITE_USER_TCC_DB } from "../errors";
34

@@ -206,12 +207,17 @@ const getEntries = (): string[] => {
206207
];
207208
};
208209

209-
export const USER_PATH = "$HOME/Library/Application Support/com.apple.TCC/TCC.db";
210+
export const USER_PATH =
211+
"$HOME/Library/Application Support/com.apple.TCC/TCC.db";
210212
export const SYSTEM_PATH = "/Library/Application Support/com.apple.TCC/TCC.db";
211213

212214
export function updateTccDb(path: string): void {
213215
for (const values of getEntries()) {
214-
const query = `INSERT OR IGNORE INTO access VALUES(${values});`;
216+
const osRelease = release();
217+
const isSonomaOrNewer = parseInt(osRelease.split(".").at(0)) >= 23;
218+
const query = `INSERT OR IGNORE INTO access VALUES(${values}${
219+
isSonomaOrNewer ? `,NULL,NULL,'UNUSED',${epoch}` : ""
220+
});`;
215221

216222
try {
217223
execSync(`sqlite3 "${path}" "${query}" >/dev/null 2>&1`);

0 commit comments

Comments
 (0)