Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow setting a custom path to where the plug-in sandbox profiles are…
… being kept

https://bugs.webkit.org/show_bug.cgi?id=97399

Reviewed by Anders Carlsson.

Add a new default to allow controlling where to look for plug-in sandbox profiles
called "PlugInSandboxProfileDirectoryPath".

* PluginProcess/mac/PluginProcessMac.mm:
(WebKit::initializeSandbox):
Use the passed in sandboxProfileDirectoryPath instead of hard coding /usr/share/sandbox/.

(WebKit::PluginProcess::platformInitialize):
* Shared/Plugins/PluginProcessCreationParameters.cpp:
(WebKit::PluginProcessCreationParameters::encode):
(WebKit::PluginProcessCreationParameters::decode):
* Shared/Plugins/PluginProcessCreationParameters.h:
(PluginProcessCreationParameters):
* UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
(WebKit::PluginProcessProxy::platformInitializePluginProcess):
Grab the sandboxProfileDirectoryPath from standardUserDefaults and pass it to
the plug-in.


Canonical link: https://commits.webkit.org/115351@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@129309 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
weinig committed Sep 22, 2012
1 parent 353e223 commit 5f2bebf
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
25 changes: 25 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,28 @@
2012-09-22 Sam Weinig <sam@webkit.org>

Allow setting a custom path to where the plug-in sandbox profiles are being kept
https://bugs.webkit.org/show_bug.cgi?id=97399

Reviewed by Anders Carlsson.

Add a new default to allow controlling where to look for plug-in sandbox profiles
called "PlugInSandboxProfileDirectoryPath".

* PluginProcess/mac/PluginProcessMac.mm:
(WebKit::initializeSandbox):
Use the passed in sandboxProfileDirectoryPath instead of hard coding /usr/share/sandbox/.

(WebKit::PluginProcess::platformInitialize):
* Shared/Plugins/PluginProcessCreationParameters.cpp:
(WebKit::PluginProcessCreationParameters::encode):
(WebKit::PluginProcessCreationParameters::decode):
* Shared/Plugins/PluginProcessCreationParameters.h:
(PluginProcessCreationParameters):
* UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
(WebKit::PluginProcessProxy::platformInitializePluginProcess):
Grab the sandboxProfileDirectoryPath from standardUserDefaults and pass it to
the plug-in.

2012-09-21 Sam Weinig <sam@webkit.org>

Fix the Lion and Snow Leopard builds.
Expand Down
14 changes: 10 additions & 4 deletions Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm
Expand Up @@ -267,8 +267,11 @@ static NSInteger replacedRunModalForWindow(id self, SEL _cmd, NSWindow* window)
}

#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
static void initializeSandbox(const String& pluginPath)
static void initializeSandbox(const String& pluginPath, const String& sandboxProfileDirectoryPath)
{
if (sandboxProfileDirectoryPath.isEmpty())
return;

RetainPtr<CFStringRef> cfPluginPath = adoptCF(pluginPath.createCFString());
RetainPtr<CFURLRef> pluginURL = adoptCF(CFURLCreateWithFileSystemPath(0, cfPluginPath.get(), kCFURLPOSIXPathStyle, false));
if (!pluginURL)
Expand All @@ -282,9 +285,12 @@ static void initializeSandbox(const String& pluginPath)
if (!bundleIdentifier)
return;

RetainPtr<CFStringRef> cfSandboxProfileDirectoryPath = adoptCF(sandboxProfileDirectoryPath.createCFString());
RetainPtr<CFURLRef> sandboxProfileDirectory = adoptCF(CFURLCreateWithFileSystemPath(0, cfSandboxProfileDirectoryPath.get(), kCFURLPOSIXPathStyle, TRUE));

RetainPtr<CFStringRef> sandboxFileName = CFStringCreateWithFormat(0, 0, CFSTR("%@.sb"), bundleIdentifier);
RetainPtr<CFURLRef> pluginSandboxDirectory = adoptCF(CFURLCreateWithFileSystemPath(0, CFSTR("/usr/share/sandbox/"), kCFURLPOSIXPathStyle, YES));
RetainPtr<CFURLRef> sandboxURL = adoptCF(CFURLCreateWithFileSystemPathRelativeToBase(0, sandboxFileName.get(), kCFURLPOSIXPathStyle, FALSE, pluginSandboxDirectory.get()));
RetainPtr<CFURLRef> sandboxURL = adoptCF(CFURLCreateWithFileSystemPathRelativeToBase(0, sandboxFileName.get(), kCFURLPOSIXPathStyle, FALSE, sandboxProfileDirectory.get()));

RetainPtr<NSString> profileString = [[NSString alloc] initWithContentsOfURL:(NSURL *)sandboxURL.get() encoding:NSUTF8StringEncoding error:NULL];
if (!profileString)
return;
Expand All @@ -306,7 +312,7 @@ static void initializeSandbox(const String& pluginPath)
WKSetVisibleApplicationName((CFStringRef)applicationName);

#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
initializeSandbox(m_pluginPath);
initializeSandbox(m_pluginPath, parameters.sandboxProfileDirectoryPath);
#endif
}

Expand Down
Expand Up @@ -47,6 +47,7 @@ void PluginProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder)
#if PLATFORM(MAC)
encoder->encode(parentProcessName);
encoder->encode(acceleratedCompositingPort);
encoder->encode(sandboxProfileDirectoryPath);
#endif
}

Expand All @@ -65,6 +66,8 @@ bool PluginProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder,
return false;
if (!decoder->decode(result.acceleratedCompositingPort))
return false;
if (!decoder->decode(result.sandboxProfileDirectoryPath))
return false;
#endif

return true;
Expand Down
Expand Up @@ -56,6 +56,7 @@ struct PluginProcessCreationParameters {
#if PLATFORM(MAC)
String parentProcessName;
CoreIPC::MachPort acceleratedCompositingPort;
String sandboxProfileDirectoryPath;
#endif
};

Expand Down
8 changes: 8 additions & 0 deletions Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm
Expand Up @@ -53,6 +53,8 @@ - (BOOL)_wantsUserAttention

@end

NSString * const WebKit2PlugInSandboxProfileDirectoryPathKey = @"WebKit2PlugInSandboxProfileDirectoryPath";

using namespace WebCore;

namespace WebKit {
Expand Down Expand Up @@ -132,6 +134,12 @@ - (BOOL)_wantsUserAttention
if (renderServerPort != MACH_PORT_NULL)
parameters.acceleratedCompositingPort = CoreIPC::MachPort(renderServerPort, MACH_MSG_TYPE_COPY_SEND);
#endif

// FIXME: We should rip this out once we have a good place to install plug-in
// sandbox profiles.
NSString* sandboxProfileDirectoryPath = [[NSUserDefaults standardUserDefaults] stringForKey:WebKit2PlugInSandboxProfileDirectoryPathKey];
if (sandboxProfileDirectoryPath)
parameters.sandboxProfileDirectoryPath = String(sandboxProfileDirectoryPath);
}

bool PluginProcessProxy::getPluginProcessSerialNumber(ProcessSerialNumber& pluginProcessSerialNumber)
Expand Down

0 comments on commit 5f2bebf

Please sign in to comment.