Imported Upstream version 878.70.2
[platform/upstream/mdnsresponder.git] / mDNSMacOSX / mDNSResponder.sb
1 ; -*- Mode: Scheme; tab-width: 4 -*-
2 ;
3 ; Copyright (c) 2012-2015 Apple Inc. All rights reserved.
4 ;
5 ; Redistribution and use in source and binary forms, with or without 
6 ; modification, are permitted provided that the following conditions are met:
7 ;
8 ; 1.  Redistributions of source code must retain the above copyright notice, 
9 ;     this list of conditions and the following disclaimer. 
10 ; 2.  Redistributions in binary form must reproduce the above copyright notice, 
11 ;     this list of conditions and the following disclaimer in the documentation 
12 ;     and/or other materials provided with the distribution. 
13 ; 3.  Neither the name of Apple Inc. ("Apple") nor the names of its 
14 ;     contributors may be used to endorse or promote products derived from this 
15 ;     software without specific prior written permission. 
16 ;
17 ; THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 
18 ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
19 ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
20 ; DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 
21 ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
22 ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
23 ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
24 ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
25 ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
26 ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 ;
28 ;############################################################################
29
30
31 ; WARNING: The sandbox rule capabilities and syntax used in this file are currently an
32 ; Apple SPI (System Private Interface) and are subject to change at any time without notice.
33
34 (version 1)
35 ; When mDNSResponder is denied access, we want to avoid symoblification of mDNSResponder
36 ; to get the stack trace as that can get into deadlock. no-callout will prevent
37 ; symbolification.
38 (deny default (with no-callout))
39
40 (import "system.sb")
41
42 ; Baseline
43 (allow file-read-metadata ipc-posix-shm)
44
45 ; Mach communications
46 ; These are needed for things like getpwnam, hostname changes, & keychain
47 (allow mach-lookup
48        (global-name "com.apple.analyticsd")
49        (global-name "com.apple.awdd")
50        (global-name "com.apple.bsd.dirhelper")
51        (global-name "com.apple.CoreServices.coreservicesd")
52        (global-name "com.apple.coreservices.quarantine-resolver")
53        (global-name "com.apple.distributed_notifications.2")
54        (global-name "com.apple.distributed_notifications@1v3")
55        (global-name "com.apple.lsd.mapdb")
56        (global-name "com.apple.ocspd")
57        (global-name "com.apple.PowerManagement.control")
58        (global-name "com.apple.mDNSResponderHelper")
59        (global-name "com.apple.mDNSResponder_Helper")
60        (global-name "com.apple.SecurityServer")
61        (global-name "com.apple.SystemConfiguration.configd")
62        (global-name "com.apple.SystemConfiguration.SCNetworkReachability")
63        (global-name "com.apple.SystemConfiguration.DNSConfiguration")
64        (global-name "com.apple.SystemConfiguration.NetworkInformation")
65        (global-name "com.apple.system.notification_center")
66        (global-name "com.apple.system.logger")
67        (global-name "com.apple.usymptomsd")
68        (global-name "com.apple.webcontentfilter.dns")
69        (global-name "com.apple.server.bluetooth")
70        (global-name "com.apple.server.bluetooth.le.att.xpc")
71        (global-name "com.apple.awacs")
72        (global-name "com.apple.networkd")
73        (global-name "com.apple.securityd")
74        (global-name "com.apple.wifi.manager")
75        ; "com.apple.blued" is the name used in pre Lobo builds,
76        ; leave it in place while still running roots on pre Lobo targets
77        (global-name "com.apple.blued")
78        (global-name "com.apple.bluetoothd")
79        (global-name "com.apple.mobilegestalt.xpc")
80        (global-name "com.apple.ReportCrash.SimulateCrash")
81        (global-name "com.apple.snhelper"))
82
83 (allow mach-register
84        (global-name "com.apple.d2d.ipc"))
85
86 ; Networking, including Unix Domain Sockets
87 (allow network*)
88
89 ; Raw sockets
90 (if (defined? 'system-socket)
91     (allow system-socket))
92
93 ; Hardware model information
94 (allow sysctl-read)
95
96 ; Syslog early in the boot process
97 (allow file-read-data file-write-data (literal "/dev/console"))
98
99 (allow file-read-data
100        ; /etc/hosts support
101        (literal "/private/etc/hosts")
102        (literal "/private/etc"))
103
104 ; Our socket
105 (allow file-read* file-write* (literal "/private/var/run/mDNSResponder"))
106
107 ; BPF control for sleep proxy server
108 (allow file-ioctl (prefix "/dev/bpf"))
109
110 ; Used by CoreCrypto AES routines.
111 (allow file-read* file-write-data file-ioctl
112            (literal "/dev/aes_0"))
113
114 ; System version, settings, and other miscellaneous necessary file system accesses
115 (allow file-read-data
116        ; Needed for CFCopyVersionDictionary()
117        (literal "/usr/sbin")
118        (literal "/usr/sbin/mDNSResponder")
119
120        (literal "/Library/Preferences/com.apple.mDNSResponder.plist")
121        (literal "/Library/Preferences/SystemConfiguration/preferences.plist")
122        (literal "/Library/Preferences/SystemConfiguration/com.apple.nat.plist")
123        (regex #"^/Library/Preferences/(ByHost/)?\.GlobalPreferences\.")
124        (literal "/Library/Preferences/com.apple.crypto.plist")
125        (literal "/Library/Security/Trust Settings/Admin.plist")
126        (regex #"^/Library/Preferences/com\.apple\.security\.")
127        (literal "/Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist")
128        (literal "/private/var/preferences/SystemConfiguration/preferences.plist")
129        (subpath "/System/Library/Preferences/Logging")
130        (subpath "/AppleInternal/Library/Preferences/Logging")
131        (subpath "/private/var/preferences/Logging/Subsystems")
132        (subpath "/private/var/db/timezone")
133        (subpath "/Library/Preferences/Logging"))
134
135
136 ; For MAC Address
137 (allow system-info (info-type "net.link.addr"))
138
139 ; We just need access to System.keychain. But we don't want errors logged if other keychains are
140 ; accessed under /Library/Keychains. Other keychains may be accessed as part of setting up an SSL
141 ; connection. Instead of adding access to it here (to things which we don't need), we disable any
142 ; logging that might happen during the access
143 (deny file-read-data (regex #"^/Library/Keychains/") (with no-log))
144 (allow file-read-data (literal "/Library/Keychains/System.keychain"))
145
146
147 ; Our Module Directory Services cache
148 (allow file-read-data
149        (subpath "/private/var/tmp/mds")
150        (subpath "/private/var/db/mds"))
151
152 (allow file-read* file-write*
153        (regex #"^/private/var/tmp/mds/[0-9]+(/|$)")
154        (regex #"^/private/var/db/mds/[0-9]+(/|$)")
155        (regex #"^/private/var/folders/[^/]+/[^/]+/C/mds(/|$)")
156
157        ; Required on 10.5 and 10.6
158        (regex #"^/private/var/folders/[^/]+/[^/]+/-Caches-/mds(/|$)"))
159
160 ; CRL Cache for SSL/TLS connections
161 (allow file-read-data (literal "/private/var/db/crls/crlcache.db"))
162
163 ; For mDNS sleep proxy offload and IOPMConnectionCreate
164 (if (defined? 'iokit-open)
165    (begin
166      (allow iokit-open
167         (iokit-user-client-class "NVEthernetUserClientMDNS")
168         (iokit-user-client-class "mDNSOffloadUserClient")
169         (iokit-user-client-class "wlDNSOffloadUserClient")
170         (iokit-user-client-class "RootDomainUserClient")
171         (iokit-user-client-class "AppleMobileFileIntegrityUserClient"))))
172
173 ; Internal builds only
174 (with-filter (system-attribute apple-internal)
175     (allow sysctl-read sysctl-write
176         (sysctl-name "vm.footprint_suspend"))) ; dyld performance reporting
177