Code Block /usr/local/bin/ffmpeg
which is actually a symlink to:
Code Block /usr/local/Cellar/ffmpeg/4.3_1/bin/ffmpeg
I'm using NSOpenPanel to let the user locate the binary and if I open the symlink I can read the contents of the binary, but I can't execute it. Same if I open the destination file.
Here is some sample code:
Code Block swift let panel = NSOpenPanel() panel.begin { response in guard response == .OK, let url = panel.url else { return } print("> \(url.path)") do { let data = try Data(contentsOf: url) print("> \(data.count) bytes") let p = Process() p.executableURL = url try p.run() } catch { print("ERROR: \(error.localizedDescription)") } }
This generates the following output:
Code Block > /usr/local/Cellar/ffmpeg/4.3_1/bin/ffmpeg > 297536 bytes ERROR: The file “ffmpeg” doesn’t exist.
Right. A sandbox has static and dynamic extensions. The static extensions represent all areas of the file system that you can access based on the way your code is signed. For example, all sandboxed apps have a static extension to access /System/Library/Frameworks, while an app signed with the com.apple.security.temporary-exception.files.absolute-path.read-only entitlement has a static extension for each path listed therein.However I do get access OK and a successful execution when I open e.g. /usr/bin/uname instead.
In contrast, a dynamic extension presents access you’re granted at runtime, via the standard file panels, drag’n’drop, AppleScript, security-scoped bookmark resolution, and so on.
/usr/bin is covered by a static extension whereas your access to /usr/local requires a dynamic one. It would seem that this dynamic extension is blocking execution.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"