2011-05-16 Maciej Stachowiak <mjs@apple.com>
[WebKit.git] / Source / WebKit2 / WebProcess / com.apple.WebProcess.sb
1 (version 1)
2 (deny default (with partial-symbolication))
3 (allow ipc-posix-shm system-audit system-socket file-read-metadata)
4
5 (import "system.sb")
6 (import "com.apple.corefoundation.sb")
7
8 ;; Distributed notifications, local pasteboard client
9 (corefoundation)
10
11 ;; Utility functions for home directory relative path filters
12 (define (home-regex home-relative-regex)
13   (regex (string-append "^" (regex-quote (param "HOME_DIR")) home-relative-regex)))
14
15 (define (home-subpath home-relative-subpath)
16   (subpath (string-append (param "HOME_DIR") home-relative-subpath)))
17
18 (define (home-literal home-relative-literal)
19   (literal (string-append (param "HOME_DIR") home-relative-literal)))
20
21 ;; Read-only preferences and data
22 (allow file-read*
23        ;; Basic system paths
24        (subpath "/Library/Dictionaries")
25        (subpath "/Library/Fonts")
26        (subpath "/Library/Frameworks")
27        (subpath "/Library/Keychains")
28        (subpath "/private/var/db/mds")
29        (subpath "/private/var/db/DetachedSignatures")
30        (regex #"^/private/etc/(hosts|group|passwd)$")
31
32        ;; Plugins
33        (subpath "/Library/Internet Plug-Ins")
34        (home-subpath "/Library/Internet Plug-Ins")
35
36        ;; System and user preferences
37        (literal "/Library/Preferences/.GlobalPreferences.plist")
38        (literal "/Library/Preferences/com.apple.crypto.plist")
39        (literal "/Library/Preferences/com.apple.security.plist")
40        (literal "/Library/Preferences/com.apple.security.common.plist")
41        (literal "/Library/Preferences/com.apple.security.revocation.plist")
42        (regex #"^/Library/Managed Preferences/[^/]+/com\.apple\.networkConnect\.plist$")
43        (home-literal "/Library/Preferences/.GlobalPreferences.plist")
44        (home-regex "/Library/Preferences/ByHost/\.GlobalPreferences\.")
45        (home-regex "/Library/Preferences/ByHost/com\.apple\.networkConnect\.")
46        (home-literal "/Library/Preferences/com.apple.ATS.plist")
47        (home-literal "/Library/Preferences/com.apple.DownloadAssessment.plist")
48        (home-literal "/Library/Preferences/com.apple.HIToolbox.plist")
49        (home-literal "/Library/Preferences/com.apple.LaunchServices.plist")
50        (home-literal "/Library/Preferences/com.apple.WebFoundation.plist")
51        (home-literal "/Library/Preferences/com.apple.security.plist")
52        (home-literal "/Library/Preferences/com.apple.security.revocation.plist")
53        (home-literal "/Library/Application Support/SyncServices/Local/ClientsWithChanges/com.apple.Keychain")
54        (home-regex "/Library/Preferences/com\.apple\.driver\.(AppleBluetoothMultitouch\.mouse|AppleBluetoothMultitouch\.trackpad|AppleHIDMouse)\.plist$")
55
56        ;; On-disk WebKit2 framework location, to account for debug installations
57        ;; outside of /System/Library/Frameworks
58        (subpath (param "WEBKIT2_FRAMEWORK_DIR"))
59
60        ;; FIXME: This should be removed when <rdar://problem/8957845> is fixed.
61        (home-subpath "/Library/Fonts")
62
63        ;; FIXME: These should be removed when <rdar://problem/9217757> is fixed.
64        (home-subpath "/Library/Audio/Plug-Ins/Components")
65        (home-subpath "/Library/Preferences/QuickTime Preferences")
66        (home-literal "/Library/Caches/com.apple.coreaudio.components.plist")
67        (subpath "/Library/Audio/Plug-Ins/Components")
68        (subpath "/Library/Audio/Plug-Ins/HAL")
69        (subpath "/Library/Video/Plug-Ins")
70        (subpath "/Library/QuickTime")
71
72        ;; FIXME: This should be removed when <rdar://problem/9237619> is fixed.
73        (home-literal "/Library/Preferences/com.apple.universalaccess.plist")
74
75        ;; FIXME: This should be removed when <rdar://problem/9276253> is fixed.
76        (home-subpath "/Library/Keyboard Layouts")
77
78        ;; FIXME: This should be removed when <rdar://problem/9276268> is fixed.
79        (home-subpath "/Library/Input Methods")
80
81        (home-subpath "/Library/Dictionaries"))
82
83 ;; This should be updated when <rdar://problem/9355830> is fixed.
84 ;; Read-only extensions from UIProcess
85 (if (defined? 'extension-class)
86     (allow file-read* (extension "com.apple.app-sandbox.read")))
87
88 ;; Read-write extensions from UIProcess
89 (allow file-read* file-write* (extension))
90
91 ;; Writable preferences and temporary files
92 (allow file*
93        (home-subpath "/Library/Caches/com.apple.WebProcess")
94        (home-regex "/Library/Preferences/ByHost/com\.apple\.HIToolbox\.")
95        (home-regex "/Library/Preferences/com\.apple\.WebProcess\.")
96        (home-subpath "/Library/Keychains")
97
98        ;; FIXME: This should be removed when <rdar://problem/9276430> is fixed.
99        (home-literal "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2")
100        (home-literal "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2-journal"))
101
102 ;; Darwin temporary files and Security mds caches, if present
103 (if (positive? (string-length (param "DARWIN_USER_CACHE_DIR")))
104     (allow file* (subpath (string-append (param "DARWIN_USER_CACHE_DIR") "/mds"))))
105 (if (positive? (string-length (param "DARWIN_USER_TEMP_DIR")))
106     (allow file* (subpath (param "DARWIN_USER_TEMP_DIR"))))
107
108 ;; Database dir
109 (if (positive? (string-length (param "WEBKIT_DATABASE_DIR")))
110     (allow file* (subpath (param "WEBKIT_DATABASE_DIR"))))
111
112 ;; LocalStorage dir
113 (if (positive? (string-length (param "WEBKIT_LOCALSTORAGE_DIR")))
114     (allow file* (subpath (param "WEBKIT_LOCALSTORAGE_DIR"))))
115
116 ;; The NSURLCache directory.
117 (if (positive? (string-length (param "NSURL_CACHE_DIR")))
118     (allow file* (subpath (param "NSURL_CACHE_DIR"))))
119
120 ;; The bundle resource path of the UI process.
121 (if (positive? (string-length (param "UI_PROCESS_BUNDLE_RESOURCE_DIR")))
122     (allow file-read* (subpath (param "UI_PROCESS_BUNDLE_RESOURCE_DIR"))))
123
124 ;; IOKit user clients
125 (allow iokit-open
126        (iokit-connection "IOAccelerator")
127        (iokit-user-client-class "IOAccelerationUserClient")
128        (iokit-user-client-class "IOFramebufferSharedUserClient")
129        (iokit-user-client-class "AppleGraphicsControlClient")
130        (iokit-user-client-class "AGPMClient")
131        (iokit-user-client-class "IOHIDParamUserClient")
132        (iokit-user-client-class "RootDomainUserClient")
133        (iokit-user-client-class "IOSurfaceRootUserClient")
134        (iokit-user-client-class "IOSurfaceSendRight")
135        (iokit-user-client-class "IOAudioControlUserClient")
136        (iokit-user-client-class "IOAudioEngineUserClient"))
137
138 ;; Various services required by AppKit and other frameworks
139 (allow mach-lookup
140        (global-name "com.apple.CoreServices.coreservicesd")
141        (global-name "com.apple.DiskArbitration.diskarbitrationd")
142        (global-name "com.apple.FileCoordination")
143        (global-name "com.apple.FontObjectsServer")
144        (global-name "com.apple.FontServer")
145        (global-name "com.apple.SecurityServer")
146        (global-name "com.apple.SystemConfiguration.configd")
147        (global-name "com.apple.SystemConfiguration.PPPController")
148        (global-name "com.apple.audio.VDCAssistant")
149        (global-name "com.apple.audio.audiohald")
150        (global-name "com.apple.audio.coreaudiod")
151        (global-name "com.apple.cookied")
152        (global-name "com.apple.cvmsServ")
153        (global-name "com.apple.networkd")
154        (global-name "com.apple.dock.server")
155        (global-name "com.apple.ocspd")
156        (global-name "com.apple.pasteboard.1")
157        (global-name "com.apple.system.opendirectoryd.api")
158        (global-name "com.apple.window_proxies")
159        (global-name "com.apple.windowserver.active")
160        (global-name-regex #"^com\.apple\.WebKit\.WebProcess-")
161
162        ;; FIXME: This should be removed when <rdar://problem/9276393> is fixed.
163        (global-name "com.apple.metadata.mds"))
164
165 (allow system-socket (socket-domain AF_ROUTE))
166 (allow system-socket (require-all (socket-domain AF_SYSTEM) (socket-protocol 2))) ; SYSPROTO_CONTROL
167 (allow network-outbound
168        ;; Kernel controls
169        (control-name "com.apple.network.statistics")
170        (control-name "com.apple.netsrc")
171
172        ;; Local mDNSResponder for DNS, arbitrary outbound TCP
173        (literal "/private/var/run/mDNSResponder")
174        (remote tcp))
175
176 ;; FIXME: Once <rdar://problem/8900275> has been fixed, these rules can be removed.
177 (allow mach-lookup (global-name "com.apple.pubsub.ipc"))
178 (allow network-outbound (regex #"^/private/tmp/launch-[^/]+/Render"))
179 (allow file-read*
180        (home-literal "/Library/Preferences/com.apple.Safari.RSS.plist")
181        (home-literal "/Library/Preferences/com.apple.Syndication.plist"))
182
183 ;; FIXME should be removed when <rdar://problem/9347205> + related radar in Safari is fixed
184 (allow mach-lookup
185        (global-name "org.h5l.kcm")
186        (global-name "com.apple.system.logger")
187        (global-name "com.apple.system.notification_center"))
188 (allow network-outbound
189        (remote udp))
190 (allow file-read*
191         (literal (string-append (param "HOME_DIR") "/Library/Preferences/com.apple.Kerberos.plist"))
192         (literal (string-append (param "HOME_DIR") "/Library/Preferences/com.apple.GSS.plist"))
193         (literal (string-append (param "HOME_DIR") "/Library/Preferences/edu.mit.Kerberos"))
194         (literal "/Library/Preferences/com.apple.Kerberos.plist")
195         (literal "/Library/Preferences/com.apple.GSS.plist")
196         (literal "/Library/Preferences/edu.mit.Kerberos")
197         (literal "/private/etc/krb5.conf")
198         (literal "/private/etc/services")
199         (literal "/private/etc/host"))