[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da
andersca at apple.com
andersca at apple.com
Wed Dec 22 17:49:03 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit cedb4b49d926bc81d59d0e4dd0be53eef89a2629
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Nov 30 21:05:47 2010 +0000
Pass the plug-in process shim in DYLD_INSERT_LIBRARIES when launching the plug-in process
https://bugs.webkit.org/show_bug.cgi?id=50262
Reviewed by Sam Weinig.
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
Add an EnvironmentVariables class that allows for easy modification of the environment variables
passed to posix_spawn.
(WebKit::ProcessLauncher::launchProcess):
When spawning the plug-in process, insert the plug-in process shim.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72957 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 698ac6e..c285e56 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -2,6 +2,20 @@
Reviewed by Sam Weinig.
+ Pass the plug-in process shim in DYLD_INSERT_LIBRARIES when launching the plug-in process
+ https://bugs.webkit.org/show_bug.cgi?id=50262
+
+ * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+ Add an EnvironmentVariables class that allows for easy modification of the environment variables
+ passed to posix_spawn.
+
+ (WebKit::ProcessLauncher::launchProcess):
+ When spawning the plug-in process, insert the plug-in process shim.
+
+2010-11-30 Anders Carlsson <andersca at apple.com>
+
+ Reviewed by Sam Weinig.
+
Add plug-in process shim
https://bugs.webkit.org/show_bug.cgi?id=50261
diff --git a/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm b/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
index 34cf400..51906ac 100644
--- a/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
+++ b/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
@@ -35,6 +35,7 @@
#include <servers/bootstrap.h>
#include <spawn.h>
#include <sys/param.h>
+#include <sys/stat.h>
#include <wtf/PassRefPtr.h>
#include <wtf/Threading.h>
#include <wtf/text/CString.h>
@@ -89,6 +90,122 @@ static void setUpTerminationNotificationHandler(pid_t pid)
#endif
}
+class EnvironmentVariables {
+ WTF_MAKE_NONCOPYABLE(EnvironmentVariables);
+
+public:
+ EnvironmentVariables()
+ : m_environmentPointer(*_NSGetEnviron())
+ {
+ }
+
+ ~EnvironmentVariables()
+ {
+ deleteAllValues(m_allocatedStrings);
+ }
+
+ void set(const char* name, const char* value)
+ {
+ // Check if we need to copy the environment.
+ if (m_environmentPointer == *_NSGetEnviron())
+ copyEnvironmentVariables();
+
+ // Allocate a string for the name and value.
+ char* nameAndValue = createStringForVariable(name, value);
+
+ for (size_t i = 0; i < m_environmentVariables.size() - 1; ++i) {
+ char* environmentVariable = m_environmentVariables[i];
+
+ if (valueIfVariableHasName(environmentVariable, name)) {
+ // Just replace the environment variable.
+ m_environmentVariables[i] = nameAndValue;
+ return;
+ }
+ }
+
+ // Append the new string.
+ ASSERT(!m_environmentVariables.last());
+ m_environmentVariables.last() = nameAndValue;
+ m_environmentVariables.append(static_cast<char*>(0));
+
+ m_environmentPointer = m_environmentVariables.data();
+ }
+
+ char* get(const char* name) const
+ {
+ for (size_t i = 0; m_environmentPointer[i]; ++i) {
+ if (char* value = valueIfVariableHasName(m_environmentPointer[i], name))
+ return value;
+ }
+ return 0;
+ }
+
+ // Will append the value with the given separator if the environment variable already exists.
+ void appendValue(const char* name, const char* value, char separator)
+ {
+ char* existingValue = get(name);
+ if (!existingValue) {
+ set(name, value);
+ return;
+ }
+
+ Vector<char, 128> newValue;
+ newValue.append(existingValue, strlen(existingValue));
+ newValue.append(separator);
+ newValue.append(value, strlen(value) + 1);
+
+ set(name, newValue.data());
+ }
+
+ char** environmentPointer() const { return m_environmentPointer; }
+
+private:
+ char *valueIfVariableHasName(const char* environmentVariable, const char* name) const
+ {
+ // Find the environment variable name.
+ char* equalsLocation = strchr(environmentVariable, '=');
+ ASSERT(equalsLocation);
+
+ size_t nameLength = equalsLocation - environmentVariable;
+ if (strncmp(environmentVariable, name, nameLength))
+ return 0;
+
+ return equalsLocation + 1;
+ }
+
+ char* createStringForVariable(const char* name, const char* value)
+ {
+ int nameLength = strlen(name);
+ int valueLength = strlen(value);
+
+ // Allocate enough room to hold 'name=value' and the null character.
+ char* string = static_cast<char*>(fastMalloc(nameLength + 1 + valueLength + 1));
+ memcpy(string, name, nameLength);
+ string[nameLength] = '=';
+ memcpy(string + nameLength + 1, value, valueLength);
+ string[nameLength + 1 + valueLength] = '\0';
+
+ m_allocatedStrings.append(string);
+
+ return string;
+ }
+
+ void copyEnvironmentVariables()
+ {
+ for (size_t i = 0; (*_NSGetEnviron())[i]; i++)
+ m_environmentVariables.append((*_NSGetEnviron())[i]);
+
+ // Null-terminate the array.
+ m_environmentVariables.append(static_cast<char*>(0));
+ }
+
+ char** m_environmentPointer;
+ Vector<char*> m_environmentVariables;
+
+ // These allocated strings will be freed in the destructor.
+ Vector<char*> m_allocatedStrings;
+};
+
void ProcessLauncher::launchProcess()
{
// Create the listening port.
@@ -141,7 +258,21 @@ void ProcessLauncher::launchProcess()
posix_spawnattr_setflags(&attr, flags);
pid_t processIdentifier;
- int result = posix_spawn(&processIdentifier, path, 0, &attr, (char *const*)args, *_NSGetEnviron());
+
+ EnvironmentVariables environmentVariables;
+
+ if (m_launchOptions.processType == ProcessLauncher::PluginProcess) {
+ // We need to insert the plug-in process shim.
+ NSString *pluginProcessShimPathNSString = [[webProcessAppExecutablePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"PluginProcessShim.dylib"];
+ const char *pluginProcessShimPath = [pluginProcessShimPathNSString fileSystemRepresentation];
+
+ // Make sure that the file exists.
+ struct stat statBuf;
+ if (stat(pluginProcessShimPath, &statBuf) == 0 && (statBuf.st_mode & S_IFMT) == S_IFREG)
+ environmentVariables.appendValue("DYLD_INSERT_LIBRARIES", pluginProcessShimPath, ':');
+ }
+
+ int result = posix_spawn(&processIdentifier, path, 0, &attr, (char *const*)args, environmentVariables.environmentPointer());
posix_spawnattr_destroy(&attr);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list