;;; Copyright (c) 2017 Apple Inc.  All Rights reserved.
;;;
;;; WARNING: The sandbox rules in this file currently constitute
;;; Apple System Private Interface and are subject to change at any time and
;;; without notice.
;;;
(version 1)

;; Enabled sandboxing
(deny default)
(deny file-map-executable process-info* nvram*)
(deny dynamic-code-generation)

(deny mach-priv-host-port)

(import "system.sb")
(import "com.apple.corefoundation.sb")
(corefoundation)

(allow process-info* (target self))

;; For resolving symlinks, realpath(3), and equivalents.
(allow file-read-metadata)

;; For validating the entitlements of clients.
(allow process-info-codesignature)

;; For consumed read token from aned/aneuserd
(allow file-read* (extension (param "SBEXTENSION")))
(allow file-read* (extension "com.apple.app-sandbox.read"))

;; Read/write access to a temporary directory.
(allow file-read* file-write*
    (subpath (param "TMPDIR")))

;; Preference domain
(deny user-preference* (with no-report))

;; Read/write cache access
(let ((cache-path-filter (subpath (param "MODELCACHEDIR"))))
  (allow file-read* file-write* cache-path-filter)
  (allow file-issue-extension
    (require-all
      (extension-class "com.apple.app-sandbox.read" "com.apple.app-sandbox.read-write")
      cache-path-filter)))

;; Allow mach-lookup
(allow mach-lookup
    (global-name "com.apple.powerlog.plxpclogger.xpc")
    (global-name "com.apple.PerfPowerTelemetryClientRegistrationService")
)

;; Open io surface driver
(allow iokit-open
        (iokit-user-client-class "IOSurfaceRootUserClient"))
