Skip to content

Commit ea59ea9

Browse files
tommusrhodusclaude
andcommitted
A new install isn't asked for the recording permissions twice
macOS refuses to withdraw permissions for an identifier it has never seen launched, which a new install's recorder is. That counted as the withdrawal having failed, so it was tried again at the next launch and took away what had been given in between. Only Oatcake's own identifier now decides whether it's done; the recorder's is tried and no more. Comments and the installer's last line say Oatcake, as macOS does. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1 parent e23df97 commit ea59ea9

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

‎Package.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ let package = Package(
2929
dependencies: ["OatcakeCore"],
3030
swiftSettings: [.swiftLanguageMode(.v6)]
3131
),
32-
// The recorder: its own app bundle inside Oatcake.app, so macOS asks for microphone and
33-
// system-audio permission for it alone.
32+
// The recorder: its own app bundle inside Oatcake.app. macOS counts the microphone and system
33+
// audio it uses as Oatcake's, and asks for them in Oatcake's name.
3434
.executableTarget(
3535
name: "OatcakeRecorder",
3636
dependencies: ["RecorderContract"],

‎Sources/OatcakeCore/Recordings.swift‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,19 @@ public enum Recordings {
7272
* release meets, and their recorders record for whoever starts them. From 0.5.0 the requirement
7373
* also says "0.5.0 or later" (Scripts/bundle.sh). So the permissions are withdrawn once, and
7474
* macOS asks again at the next recording: given to this version, they no longer cover an
75-
* earlier copy of Oatcake that something else has started. The recorder's own identifier is
76-
* done too, in case a version of macOS remembers them against that. False when macOS wouldn't.
75+
* earlier copy of Oatcake that something else has started. False when macOS wouldn't.
76+
*
77+
* The recorder's own identifier is done too, in case a version of macOS remembers them against
78+
* that, but it doesn't count towards the answer: macOS refuses an identifier it has never seen
79+
* launched, as a new install's recorder is, and trying again later would take away permissions
80+
* that had been given since.
7781
*/
7882
public static func withdrawEarlierPermissions(of bundleID: String) -> Bool {
79-
[bundleID, bundleID + ".recorder"].allSatisfy { id in
80-
["Microphone", "AudioCapture"].allSatisfy { (try? runCapturing("/usr/bin/tccutil", ["reset", $0, id])) != nil }
83+
func withdraw(_ id: String) -> Bool {
84+
["Microphone", "AudioCapture"].map { (try? runCapturing("/usr/bin/tccutil", ["reset", $0, id])) != nil }.allSatisfy { $0 }
8185
}
86+
_ = withdraw(bundleID + ".recorder")
87+
return withdraw(bundleID)
8288
}
8389

8490
static var recorderBinary: URL { recorderApp.appendingPathComponent("Contents/MacOS/oatcake-recorder") }
@@ -128,7 +134,8 @@ public enum Recordings {
128134
try writeAtomic(dir.appendingPathComponent(RecorderFile.owner), String(getpid()))
129135
// The recorder only records for Oatcake: it asks at this socket whether this folder's recording is wanted.
130136
let socket = try door.expect(dir)
131-
// Launched through LaunchServices so macOS treats the recorder as its own app for permissions.
137+
// Launched through LaunchServices, so it runs as an app of its own and not as Oatcake's child
138+
// (macOS still counts the microphone and system audio it uses as Oatcake's).
132139
do {
133140
try runCapturing("/usr/bin/open", ["-n", "-g", recorderApp.path, "--args", "--out", dir.path, RecorderGate.argument, socket])
134141
} catch {

‎install.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ main() {
169169

170170
say ""
171171
say "Installed Oatcake $VERSION in $DEST_DIR."
172-
say "The first recording asks for microphone and system-audio permission for \"OatcakeRecorder\"; allow both."
172+
say "The first recording asks for microphone and system-audio permission for Oatcake; allow both."
173173
say "Summaries are written on this Mac. Oatcake downloads the model for them (2.5 to 5 GB) during your first call."
174174
say "Oatcake checks for updates itself from now on (Settings > Updates)."
175175
}

0 commit comments

Comments
 (0)