Search code examples
swiftswift3sandbox

accessing /var/log/jamf.log with sandboxed


I'm trying to parse /var/log/jamf.log (line by line), while having a sandboxed application.

My entitlements file:

<dict>
    <key>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.temporary-exception.files.absolute-path.read-write</key>
    <array>
        <string>/var/log/jamf.log</string>
    </array>
</dict>

(I also tried with .read-only)

Running code:

do {
    self.logFileHandle = try FileHandle(forReadingFrom: URL(fileURLWithPath: "/var/log/jamf.log", isDirectory: false))
} catch {
    dump(error)
    self.logFileHandle = nil
}

With this, I get the following error:

Error Domain=NSCocoaErrorDomain Code=1 "(null)" UserInfo={NSFilePath=/var/log/jamf.log}

Anyone has an idea? Is it possible that / corresponds to the root of the sandbox?

Thanks!

François


Solution

  • Kudos to Pepijn Bruienne:

    The path needs to be /private/var/log/jamf.log as /var/log is a symlink…