Changeset 140926 in webkit
- Timestamp:
- Jan 26, 2013, 11:02:45 PM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r140924 r140926 1 2013-01-26 Alexey Proskuryakov <ap@apple.com> 2 3 Use shared ChildProcess code to enter plug-in sandbox. 4 5 Reviewed by Sam Weinig. 6 7 There is one known behavior change from this refactoring: getpwuid_r is used 8 instead of NSHomeDirectory for home directory, mathcing other client processes. 9 10 * PluginProcess/PluginProcess.cpp: (WebKit::PluginProcess::enterSandbox): 11 * PluginProcess/PluginProcess.h: 12 PluginProcess prevents ChildProcess attempt to enter the sandbox immediately on 13 launch for now, because we don't have a sandbox profile directory path yet. 14 It now keeps a copy of ChildProcessInitializationParameters, so that 15 ChildProcess::initializeSandbox() could be called later. 16 17 * PluginProcess/mac/PluginProcessMac.mm: 18 (WebKit::PluginProcess::platformInitializeProcess): Store a copy of ChildProcessInitializationParameters 19 for later. 20 (WebKit::loadSandboxProfile): Build a sandbox profile from a common prefix and 21 a plugin-specific part. 22 (WebKit::PluginProcess::platformInitializePluginProcess): We can enter the sandbox now. 23 (WebKit::PluginProcess::enterSandbox): Prepare SandboxInitializationParameters, 24 and call ChildProcess::initializeSandbox(). 25 26 * Shared/mac/ChildProcessMac.mm: 27 (WebKit::ChildProcess::initializeSandbox): Actually handle system directory suffix 28 from parameters. 29 30 * WebKit2.xcodeproj/project.pbxproj: 31 * WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.h: Removed. 32 * WebProcess/Plugins/Netscape/mac/NetscapeSandboxFunctions.mm: Removed. 33 1 34 2013-01-26 Sam Weinig <sam@webkit.org> 2 35 -
trunk/Source/WebKit2/PluginProcess/PluginProcess.cpp
r139257 r140926 91 91 } 92 92 93 #if !PLATFORM(MAC) 94 void PluginProcess::enterSandbox(const String&) 95 { 96 } 97 #endif 98 93 99 void PluginProcess::removeWebProcessConnection(WebProcessConnection* webProcessConnection) 94 100 { -
trunk/Source/WebKit2/PluginProcess/PluginProcess.h
r140730 r140926 73 73 ~PluginProcess(); 74 74 75 void enterSandbox(const String& sandboxProfileDirectoryPath); 76 75 77 // ChildProcess 76 78 virtual void initializeProcess(const ChildProcessInitializationParameters&) OVERRIDE; 77 79 virtual bool shouldTerminate() OVERRIDE; 78 80 79 // FIXME: PluginProcess should switch to common code for sandbox initialization. 81 // Prevent entering the sandbox during first stage of process initialization. We can't do enter the sandbox before receiving 82 // sandbox profile directory in initialization message. 80 83 virtual void initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&) OVERRIDE { } 81 84 … … 99 102 void minimumLifetimeTimerFired(); 100 103 104 // Stored for delayed sandbox initialization. 105 ChildProcessInitializationParameters m_childProcessInitializationParameters; 106 101 107 // Our web process connections. 102 108 Vector<RefPtr<WebProcessConnection> > m_webProcessConnections; … … 111 117 112 118 WebCore::RunLoop::Timer<PluginProcess> m_minimumLifetimeTimer; 113 119 114 120 #if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC) 115 121 // The Mach port used for accelerated compositing. 116 122 mach_port_t m_compositingRenderServerPort; 117 123 #endif 118 119 124 }; 120 125 -
trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm
r140865 r140926 34 34 #import "PluginProcessProxyMessages.h" 35 35 #import "PluginProcessCreationParameters.h" 36 #import "SandboxInitializationParameters.h" 36 37 #import <CoreAudio/AudioHardware.h> 37 38 #import <WebCore/LocalizedStrings.h> … … 39 40 #import <dlfcn.h> 40 41 #import <objc/runtime.h> 42 #import <sysexits.h> 41 43 #import <wtf/HashSet.h> 42 43 #import "NetscapeSandboxFunctions.h"44 44 45 45 using namespace WebCore; … … 271 271 } 272 272 273 void PluginProcess::platformInitializeProcess(const ChildProcessInitializationParameters&) 274 { 273 void PluginProcess::platformInitializeProcess(const ChildProcessInitializationParameters& parameters) 274 { 275 m_childProcessInitializationParameters = parameters; 276 275 277 RunLoop::setUseApplicationRunLoopOnMainRunLoop(); 276 278 … … 304 306 } 305 307 306 static void initializeSandbox(const String& pluginPath, const String& sandboxProfileDirectoryPath)308 static String loadSandboxProfile(const String& pluginPath, const String& sandboxProfileDirectoryPath) 307 309 { 308 310 if (sandboxProfileDirectoryPath.isEmpty()) 309 return ;311 return String(); 310 312 311 313 RetainPtr<CFURLRef> pluginURL = adoptCF(CFURLCreateWithFileSystemPath(0, pluginPath.createCFString().get(), kCFURLPOSIXPathStyle, false)); 312 314 if (!pluginURL) 313 return ;315 return String(); 314 316 315 317 RetainPtr<CFBundleRef> pluginBundle = adoptCF(CFBundleCreate(kCFAllocatorDefault, pluginURL.get())); 316 318 if (!pluginBundle) 317 return ;319 return String(); 318 320 319 321 CFStringRef bundleIdentifier = CFBundleGetIdentifier(pluginBundle.get()); 320 322 if (!bundleIdentifier) 321 return ;323 return String(); 322 324 323 325 RetainPtr<CFURLRef> sandboxProfileDirectory = adoptCF(CFURLCreateWithFileSystemPath(0, sandboxProfileDirectoryPath.createCFString().get(), kCFURLPOSIXPathStyle, TRUE)); … … 328 330 RetainPtr<NSString> profileString = adoptNS([[NSString alloc] initWithContentsOfURL:(NSURL *)sandboxURL.get() encoding:NSUTF8StringEncoding error:NULL]); 329 331 if (!profileString) 330 return ;332 return String(); 331 333 332 334 sandboxURL = adoptCF(CFURLCreateWithFileSystemPathRelativeToBase(0, CFSTR("com.apple.WebKit.plugin-common.sb"), kCFURLPOSIXPathStyle, FALSE, sandboxProfileDirectory.get())); … … 334 336 RetainPtr<NSString> commonProfileString = adoptNS([[NSString alloc] initWithContentsOfURL:(NSURL *)sandboxURL.get() encoding:NSUTF8StringEncoding error:NULL]); 335 337 if (!commonProfileString) 336 return; 337 338 profileString = [commonProfileString.get() stringByAppendingString:profileString.get()]; 339 340 enterSandbox([profileString.get() UTF8String]); 338 return String(); 339 340 return [commonProfileString.get() stringByAppendingString:profileString.get()]; 341 341 } 342 342 … … 361 361 WKSetVisibleApplicationName((CFStringRef)applicationName); 362 362 363 // FIXME: Use ChildProcess::initializeSandbox. 364 WebKit::initializeSandbox(m_pluginPath, parameters.sandboxProfileDirectoryPath); 363 // FIXME: PluginProcess initializes sandbox later than normal for ChildProcesses, because it needs 364 // to know profile directory path. Switch to normal initialization scheme once the path can be determined earlier. 365 enterSandbox(parameters.sandboxProfileDirectoryPath); 365 366 366 367 if (parameters.processType == TypeSnapshotProcess) … … 368 369 } 369 370 371 void PluginProcess::enterSandbox(const String& sandboxProfileDirectoryPath) 372 { 373 SandboxInitializationParameters sandboxParameters; 374 375 String sandboxProfile = loadSandboxProfile(m_pluginPath, sandboxProfileDirectoryPath); 376 if (sandboxProfile.isEmpty()) 377 return; 378 379 sandboxParameters.setSandboxProfile(sandboxProfile); 380 381 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 382 // Use private temporary and cache directories. 383 char temporaryDirectory[PATH_MAX]; 384 if (!confstr(_CS_DARWIN_USER_TEMP_DIR, temporaryDirectory, sizeof(temporaryDirectory))) { 385 WTFLogAlways("PluginProcess: couldn't retrieve system temporary directory path: %d\n", errno); 386 exit(EX_OSERR); 387 } 388 389 if (strlcpy(temporaryDirectory, [[[[NSFileManager defaultManager] stringWithFileSystemRepresentation:temporaryDirectory length:strlen(temporaryDirectory)] stringByAppendingPathComponent:@"WebKitPlugin-XXXXXX"] fileSystemRepresentation], sizeof(temporaryDirectory)) >= sizeof(temporaryDirectory) 390 || !mkdtemp(temporaryDirectory)) { 391 WTFLogAlways("PluginProcess: couldn't create private temporary directory '%s'\n", temporaryDirectory); 392 exit(EX_OSERR); 393 } 394 395 sandboxParameters.setSystemDirectorySuffix([[[[NSFileManager defaultManager] stringWithFileSystemRepresentation:temporaryDirectory length:strlen(temporaryDirectory)] lastPathComponent] fileSystemRepresentation]); 396 #endif 397 398 sandboxParameters.addPathParameter("PLUGIN_PATH", m_pluginPath); 399 400 RetainPtr<CFStringRef> cachePath(AdoptCF, WKCopyFoundationCacheDirectory()); 401 sandboxParameters.addPathParameter("NSURL_CACHE_DIR", (NSString *)cachePath.get()); 402 403 RetainPtr<NSDictionary> defaults = adoptNS([[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"NSUseRemoteSavePanel", nil]); 404 [[NSUserDefaults standardUserDefaults] registerDefaults:defaults.get()]; 405 406 ChildProcess::initializeSandbox(m_childProcessInitializationParameters, sandboxParameters); 407 } 408 370 409 } // namespace WebKit 371 410 -
trunk/Source/WebKit2/Shared/mac/ChildProcessMac.mm
r140853 r140926 86 86 String defaultProfilePath = [webkit2Bundle pathForResource:[[NSBundle mainBundle] bundleIdentifier] ofType:@"sb"]; 87 87 88 String defaultSystemDirectorySuffix = String([[NSBundle mainBundle] bundleIdentifier]) + "+" + parameters.clientIdentifier; 89 sandboxParameters.setSystemDirectorySuffix(defaultSystemDirectorySuffix); 88 if (sandboxParameters.systemDirectorySuffix().isNull()) { 89 String defaultSystemDirectorySuffix = String([[NSBundle mainBundle] bundleIdentifier]) + "+" + parameters.clientIdentifier; 90 sandboxParameters.setSystemDirectorySuffix(defaultSystemDirectorySuffix); 91 } 90 92 91 93 sandboxParameters.addPathParameter("WEBKIT2_FRAMEWORK_DIR", [[webkit2Bundle bundlePath] stringByDeletingLastPathComponent]); -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r140924 r140926 1042 1042 E179FD9C134D38060015B883 /* ArgumentCodersMac.h in Headers */ = {isa = PBXBuildFile; fileRef = E179FD9B134D38060015B883 /* ArgumentCodersMac.h */; }; 1043 1043 E179FD9F134D38250015B883 /* ArgumentCodersMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E179FD9E134D38250015B883 /* ArgumentCodersMac.mm */; }; 1044 E17BF99614D0A73E00A5A069 /* NetscapeSandboxFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E17BF99514D0A73E00A5A069 /* NetscapeSandboxFunctions.h */; };1045 E17BF99814D0AA8300A5A069 /* NetscapeSandboxFunctions.mm in Sources */ = {isa = PBXBuildFile; fileRef = E17BF99714D0AA8300A5A069 /* NetscapeSandboxFunctions.mm */; };1046 1044 E18C92F412DB9E7100CF2AEB /* PrintInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E18C92F312DB9E7100CF2AEB /* PrintInfo.cpp */; }; 1047 1045 E18E690B169B563F009B6670 /* SecItemShimProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E18E6909169B563F009B6670 /* SecItemShimProxy.cpp */; }; … … 2387 2385 E179FD9B134D38060015B883 /* ArgumentCodersMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArgumentCodersMac.h; sourceTree = "<group>"; }; 2388 2386 E179FD9E134D38250015B883 /* ArgumentCodersMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ArgumentCodersMac.mm; sourceTree = "<group>"; }; 2389 E17BF99514D0A73E00A5A069 /* NetscapeSandboxFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetscapeSandboxFunctions.h; sourceTree = "<group>"; };2390 E17BF99714D0AA8300A5A069 /* NetscapeSandboxFunctions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetscapeSandboxFunctions.mm; sourceTree = "<group>"; };2391 2387 E18C92F312DB9E7100CF2AEB /* PrintInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrintInfo.cpp; sourceTree = "<group>"; }; 2392 2388 E18E6909169B563F009B6670 /* SecItemShimProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecItemShimProxy.cpp; sourceTree = "<group>"; }; … … 2765 2761 children = ( 2766 2762 1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.mm */, 2767 E17BF99514D0A73E00A5A069 /* NetscapeSandboxFunctions.h */,2768 E17BF99714D0AA8300A5A069 /* NetscapeSandboxFunctions.mm */,2769 2763 1A2D92201281DC1B001EB962 /* PluginProxyMac.mm */, 2770 2764 ); … … 4795 4789 1A4A9C5612B816CF008FE984 /* NetscapePluginModule.h in Headers */, 4796 4790 1AA5889211EE70400061B882 /* NetscapePluginStream.h in Headers */, 4797 E17BF99614D0A73E00A5A069 /* NetscapeSandboxFunctions.h in Headers */,4798 4791 513A164D1630A9BF005D7D22 /* NetworkConnectionToWebProcess.h in Headers */, 4799 4792 51DD9F2916367DA2001578E9 /* NetworkConnectionToWebProcessMessages.h in Headers */, … … 5826 5819 1A4A9C9A12B821CD008FE984 /* NetscapePluginModuleMac.mm in Sources */, 5827 5820 1AA5889311EE70400061B882 /* NetscapePluginStream.cpp in Sources */, 5828 E17BF99814D0AA8300A5A069 /* NetscapeSandboxFunctions.mm in Sources */,5829 5821 513A164C1630A9BF005D7D22 /* NetworkConnectionToWebProcess.cpp in Sources */, 5830 5822 51DD9F2816367DA2001578E9 /* NetworkConnectionToWebProcessMessageReceiver.cpp in Sources */,
Note:
See TracChangeset
for help on using the changeset viewer.