I have a brand new AppKit App Delegate based application to showcase the issue I'm having.
I've set "User Selected File" in the sandbox entitlements to none.
I've changed the app delegate file to the following.
This code gets all files in the /Library/LaunchDaemons path, prints their url and also prints their content.
At this point I'm confused. I was under the impression the sandbox is supposed to be blocking this code? Instead, the fileUrl and the contents are happily printed out.
Is my understanding of sandbox incorrect? Why is this code able to run?
I've set "User Selected File" in the sandbox entitlements to none.
I've changed the app delegate file to the following.
Code Block import Cocoa import SwiftUI @main class AppDelegate: NSObject, NSApplicationDelegate { var window: NSWindow! func applicationDidFinishLaunching(_ aNotification: Notification) { let url = URL(fileURLWithPath: "/Library/LaunchDaemons") if let enumerator = FileManager.default.enumerator(at: url, includingPropertiesForKeys: [.isRegularFileKey, .isDirectoryKey], options: [.skipsHiddenFiles, .skipsPackageDescendants]) { for case let fileURL as URL in enumerator { print(fileURL); do { let contents = try String(contentsOf: fileURL, encoding: .utf8) print(contents) } catch { } } } } func applicationWillTerminate(_ aNotification: Notification) { // Insert code here to tear down your application } }
This code gets all files in the /Library/LaunchDaemons path, prints their url and also prints their content.
At this point I'm confused. I was under the impression the sandbox is supposed to be blocking this code? Instead, the fileUrl and the contents are happily printed out.
Is my understanding of sandbox incorrect? Why is this code able to run?