Skip to content

Commit fac3779

Browse files
Engagendyclaude
andcommitted
Use /bin/sh to launch Java process to bypass Gatekeeper restrictions
When macOS downloads an app, Gatekeeper/translocation can prevent direct execution of bundled binaries via Process.executableURL. Using /bin/sh -c to invoke the java binary avoids this issue. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 65696d8 commit fac3779

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

MPPViewer/MPPViewer/Services/MPPConverterService.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,15 @@ final class MPPConverterService {
183183
) async throws {
184184
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
185185
let process = Process()
186-
process.executableURL = URL(fileURLWithPath: javaPath)
187-
process.arguments = ["-jar", jarPath, inputPath, outputPath]
186+
// Use /bin/sh to invoke java to avoid Gatekeeper/translocation
187+
// issues with directly executing bundled binaries
188+
process.executableURL = URL(fileURLWithPath: "/bin/sh")
189+
190+
let escapedJava = javaPath.replacingOccurrences(of: "'", with: "'\\''")
191+
let escapedJar = jarPath.replacingOccurrences(of: "'", with: "'\\''")
192+
let escapedInput = inputPath.replacingOccurrences(of: "'", with: "'\\''")
193+
let escapedOutput = outputPath.replacingOccurrences(of: "'", with: "'\\''")
194+
process.arguments = ["-c", "'\(escapedJava)' -jar '\(escapedJar)' '\(escapedInput)' '\(escapedOutput)'"]
188195

189196
let stderrPipe = Pipe()
190197
let stdoutPipe = Pipe()

0 commit comments

Comments
 (0)