+2011-02-03 Ivan Krstić <ike@apple.com>
+
+ Reviewed by Maciej Stachowiak.
+
+ Make WebProcess pass explicit homedir parameter to the sandbox
+ <rdar://problem/8405760>
+ <https://webkit.org/b/53558>
+
+ * WebProcess/com.apple.WebProcess.sb:
+ * WebProcess/mac/WebProcessMac.mm:
+ (WebKit::initializeSandbox):
+
2011-02-03 James Kozianski <koz@chromium.org>
Reviewed by Dimitri Glazkov.
;; Plugins
(subpath "/Library/Internet Plug-Ins")
- (subpath (string-append (param "_HOME") "/Library/Internet Plug-Ins"))
+ (subpath (string-append (param "HOME_DIR") "/Library/Internet Plug-Ins"))
;; System and user preferences
(literal "/Library/Preferences/.GlobalPreferences.plist")
(literal "/Library/Preferences/com.apple.security.plist")
- (literal (string-append (param "_HOME") "/Library/Preferences/.GlobalPreferences.plist"))
- (regex (string-append "^" (param "_HOME") "/Library/Preferences/ByHost/\.GlobalPreferences\."))
- (literal (string-append (param "_HOME") "/Library/Preferences/com.apple.ATS.plist"))
- (literal (string-append (param "_HOME") "/Library/Preferences/com.apple.HIToolbox.plist"))
- (literal (string-append (param "_HOME") "/Library/Preferences/com.apple.LaunchServices.plist"))
- (literal (string-append (param "_HOME") "/Library/Preferences/com.apple.WebFoundation.plist"))
- (literal (string-append (param "_HOME") "/Library/Preferences/com.apple.security.plist"))
- (literal (string-append (param "_HOME") "/Library/Preferences/com.apple.security.revocation.plist"))
- (subpath (string-append (param "_HOME") "/Library/Keychains"))
+ (literal (string-append (param "HOME_DIR") "/Library/Preferences/.GlobalPreferences.plist"))
+ (regex (string-append "^" (param "HOME_DIR") "/Library/Preferences/ByHost/\.GlobalPreferences\."))
+ (literal (string-append (param "HOME_DIR") "/Library/Preferences/com.apple.ATS.plist"))
+ (literal (string-append (param "HOME_DIR") "/Library/Preferences/com.apple.HIToolbox.plist"))
+ (literal (string-append (param "HOME_DIR") "/Library/Preferences/com.apple.LaunchServices.plist"))
+ (literal (string-append (param "HOME_DIR") "/Library/Preferences/com.apple.WebFoundation.plist"))
+ (literal (string-append (param "HOME_DIR") "/Library/Preferences/com.apple.security.plist"))
+ (literal (string-append (param "HOME_DIR") "/Library/Preferences/com.apple.security.revocation.plist"))
+ (subpath (string-append (param "HOME_DIR") "/Library/Keychains"))
;; On-disk WebKit2 framework location, to account for debug installations
;; outside of /System/Library/Frameworks
;; Writable preferences and temporary files
(allow file*
- (subpath (string-append (param "_HOME") "/Library/Caches/com.apple.WebProcess"))
- (regex (string-append "^" (param "_HOME") "/Library/Preferences/ByHost/com\.apple\.HIToolbox\."))
- (regex (string-append "^" (param "_HOME") "/Library/Preferences/com\.apple\.WebProcess\."))
+ (subpath (string-append (param "HOME_DIR") "/Library/Caches/com.apple.WebProcess"))
+ (regex (string-append "^" (param "HOME_DIR") "/Library/Preferences/ByHost/com\.apple\.HIToolbox\."))
+ (regex (string-append "^" (param "HOME_DIR") "/Library/Preferences/com\.apple\.WebProcess\."))
)
;; Darwin temporary files and caches, if present
;; FIXME: These rules are required until plug-ins are moved out of the web process.
(allow file-read*
- (regex (string-append "^" (param "_HOME") "/Library/Preferences/ByHost/com\.apple\.ist\."))
- (literal (string-append (param "_HOME") "/Library/Preferences/edu.mit.Kerberos"))
+ (regex (string-append "^" (param "HOME_DIR") "/Library/Preferences/ByHost/com\.apple\.ist\."))
+ (literal (string-append (param "HOME_DIR") "/Library/Preferences/edu.mit.Kerberos"))
(literal "/Library/Preferences/edu.mit.Kerberos")
)
char* errorBuf;
char tmpPath[PATH_MAX];
char tmpRealPath[PATH_MAX];
+ char homeRealPath[PATH_MAX];
char cachePath[PATH_MAX];
char cacheRealPath[PATH_MAX];
const char* frameworkPath = [[[[NSBundle bundleForClass:NSClassFromString(@"WKView")] bundlePath] stringByDeletingLastPathComponent] UTF8String];
const char* profilePath = [[[NSBundle mainBundle] pathForResource:@"com.apple.WebProcess" ofType:@"sb"] UTF8String];
+ if (!realpath([NSHomeDirectory() UTF8String], homeRealPath)) {
+ fprintf(stderr, "WebProcess: couldn't determine home directory when initializing sandbox");
+ exit(EX_CONFIG);
+ }
+
if (confstr(_CS_DARWIN_USER_TEMP_DIR, tmpPath, PATH_MAX) <= 0 || !realpath(tmpPath, tmpRealPath))
tmpRealPath[0] = '\0';
cacheRealPath[0] = '\0';
const char* const sandboxParam[] = {
+ "HOME_DIR", (const char*)homeRealPath,
"WEBKIT2_FRAMEWORK_DIR", frameworkPath,
"DARWIN_USER_TEMP_DIR", (const char*)tmpRealPath,
"DARWIN_USER_CACHE_DIR", (const char*)cacheRealPath,