Title: [183209] trunk/Source
Revision
183209
Author
[email protected]
Date
2015-04-23 14:14:56 -0700 (Thu, 23 Apr 2015)

Log Message

[iOS] WebKit services should inherit environment variables for home
https://bugs.webkit.org/show_bug.cgi?id=144078
rdar://problem/20571678

Reviewed by Dan Bernstein.

Source/WebCore:

Added an SPI header for a drive-by fix.

* WebCore.xcodeproj/project.pbxproj:
* platform/spi/cf/CFBundleSPI.h: Added.

Source/WebKit2:

Pass current environment variables as XPC bootstrap. Also while at it, made
_CFBundleSetupXPCBootstrap not soft linked.

* Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm:
(main):
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::connectToService):

Source/WTF:

* wtf/spi/darwin/XPCSPI.h: Added xpc_copy_bootstrap and xpc_dictionary_apply.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (183208 => 183209)


--- trunk/Source/WTF/ChangeLog	2015-04-23 21:03:46 UTC (rev 183208)
+++ trunk/Source/WTF/ChangeLog	2015-04-23 21:14:56 UTC (rev 183209)
@@ -1,5 +1,15 @@
 2015-04-23  Alexey Proskuryakov  <[email protected]>
 
+        [iOS] WebKit services should inherit environment variables for home
+        https://bugs.webkit.org/show_bug.cgi?id=144078
+        rdar://problem/20571678
+
+        Reviewed by Dan Bernstein.
+
+        * wtf/spi/darwin/XPCSPI.h: Added xpc_copy_bootstrap and xpc_dictionary_apply.
+
+2015-04-23  Alexey Proskuryakov  <[email protected]>
+
         Undo the WTF part of the previous build fix, we don't use private headers in WTF.
 
         * WTF.xcodeproj/project.pbxproj:

Modified: trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h (183208 => 183209)


--- trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h	2015-04-23 21:03:46 UTC (rev 183208)
+++ trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h	2015-04-23 21:14:56 UTC (rev 183209)
@@ -58,6 +58,7 @@
 
 #if COMPILER_SUPPORTS(BLOCKS)
 typedef bool (^xpc_array_applier_t)(size_t index, xpc_object_t);
+typedef bool (^xpc_dictionary_applier_t)(const char *key, xpc_object_t value);
 typedef void (^xpc_handler_t)(xpc_object_t);
 #endif
 
@@ -98,6 +99,7 @@
 EXTERN_C xpc_object_t xpc_array_create(const xpc_object_t*, size_t count);
 #if COMPILER_SUPPORTS(BLOCKS)
 EXTERN_C bool xpc_array_apply(xpc_object_t, xpc_array_applier_t);
+EXTERN_C bool xpc_dictionary_apply(xpc_object_t xdict, xpc_dictionary_applier_t applier);
 #endif
 EXTERN_C size_t xpc_array_get_count(xpc_object_t);
 EXTERN_C const char* xpc_array_get_string(xpc_object_t, size_t index);
@@ -142,6 +144,7 @@
 
 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
 EXTERN_C void xpc_connection_set_bootstrap(xpc_connection_t, xpc_object_t bootstrap);
+EXTERN_C xpc_object_t xpc_copy_bootstrap(void);
 #endif
 
 #if !defined(xpc_retain) && OS_OBJECT_USE_OBJC_RETAIN_RELEASE

Modified: trunk/Source/WebCore/ChangeLog (183208 => 183209)


--- trunk/Source/WebCore/ChangeLog	2015-04-23 21:03:46 UTC (rev 183208)
+++ trunk/Source/WebCore/ChangeLog	2015-04-23 21:14:56 UTC (rev 183209)
@@ -1,3 +1,16 @@
+2015-04-22  Alexey Proskuryakov  <[email protected]>
+
+        [iOS] WebKit services should inherit environment variables for home
+        https://bugs.webkit.org/show_bug.cgi?id=144078
+        rdar://problem/20571678
+
+        Reviewed by Dan Bernstein.
+
+        Added an SPI header for a drive-by fix.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/spi/cf/CFBundleSPI.h: Added.
+
 2015-04-23  Alex Christensen  <[email protected]>
 
         Use less memory when compiling content extensions.

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (183208 => 183209)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-04-23 21:03:46 UTC (rev 183208)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-04-23 21:14:56 UTC (rev 183209)
@@ -5998,6 +5998,7 @@
 		E0FEF372B47C53EAC1C1FBEE /* JSEventSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E0FEF371B47C53EAC1C1FBEE /* JSEventSource.cpp */; };
 		E107400D0E77BDC00033AF24 /* JSMessageChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E107400B0E77BDC00033AF24 /* JSMessageChannel.cpp */; };
 		E107400E0E77BDC00033AF24 /* JSMessageChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = E107400C0E77BDC00033AF24 /* JSMessageChannel.h */; };
+		E10A39E21AE84E7100A29AE3 /* CFBundleSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = E10A39E11AE84E7100A29AE3 /* CFBundleSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E10B937C0B73C00A003ED890 /* JSCustomXPathNSResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = E10B937B0B73C00A003ED890 /* JSCustomXPathNSResolver.h */; };
 		E10B93C30B73C291003ED890 /* JSCustomXPathNSResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E10B93C20B73C291003ED890 /* JSCustomXPathNSResolver.cpp */; };
 		E10B9B6C0B747599003ED890 /* NativeXPathNSResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = E10B9B6A0B747599003ED890 /* NativeXPathNSResolver.h */; };
@@ -13604,6 +13605,7 @@
 		E0FEF371B47C53EAC1C1FBEE /* JSEventSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEventSource.cpp; sourceTree = "<group>"; };
 		E107400B0E77BDC00033AF24 /* JSMessageChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMessageChannel.cpp; sourceTree = "<group>"; };
 		E107400C0E77BDC00033AF24 /* JSMessageChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMessageChannel.h; sourceTree = "<group>"; };
+		E10A39E11AE84E7100A29AE3 /* CFBundleSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFBundleSPI.h; sourceTree = "<group>"; };
 		E10B937B0B73C00A003ED890 /* JSCustomXPathNSResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomXPathNSResolver.h; sourceTree = "<group>"; };
 		E10B93C20B73C291003ED890 /* JSCustomXPathNSResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomXPathNSResolver.cpp; sourceTree = "<group>"; };
 		E10B9B6A0B747599003ED890 /* NativeXPathNSResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeXPathNSResolver.h; sourceTree = "<group>"; };
@@ -16491,6 +16493,7 @@
 		65086DA619AC1719009AF46B /* cf */ = {
 			isa = PBXGroup;
 			children = (
+				E10A39E11AE84E7100A29AE3 /* CFBundleSPI.h */,
 				65086DA719AC1719009AF46B /* CFLocaleSPI.h */,
 				CE8245EF19B671BA00AC0122 /* CFNetworkConnectionCacheSPI.h */,
 				CE12525A1A1C018200864480 /* CFNetworkSPI.h */,
@@ -27155,6 +27158,7 @@
 				2E4346510F546A8200B0F1BA /* WorkerObjectProxy.h in Headers */,
 				416E29A6102FA962007FC14E /* WorkerReportingProxy.h in Headers */,
 				2E4346530F546A8200B0F1BA /* WorkerRunLoop.h in Headers */,
+				E10A39E21AE84E7100A29AE3 /* CFBundleSPI.h in Headers */,
 				F3820899147D35F90010BC06 /* WorkerRuntimeAgent.h in Headers */,
 				E1A643F20EC0972500779668 /* WorkerScriptController.h in Headers */,
 				F34742E91343635000531BC2 /* WorkerScriptDebugServer.h in Headers */,

Added: trunk/Source/WebCore/platform/spi/cf/CFBundleSPI.h (0 => 183209)


--- trunk/Source/WebCore/platform/spi/cf/CFBundleSPI.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/spi/cf/CFBundleSPI.h	2015-04-23 21:14:56 UTC (rev 183209)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2015 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef CFBundleSPI_h
+#define CFBundleSPI_h
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#if USE(APPLE_INTERNAL_SDK)
+#import <CoreFoundation/CFPriv.h>
+#else
+#include <wtf/spi/darwin/XPCSPI.h>
+#endif
+
+extern "C" {
+void _CFBundleSetupXPCBootstrap(xpc_object_t bootstrap);
+}
+
+#endif

Modified: trunk/Source/WebKit2/ChangeLog (183208 => 183209)


--- trunk/Source/WebKit2/ChangeLog	2015-04-23 21:03:46 UTC (rev 183208)
+++ trunk/Source/WebKit2/ChangeLog	2015-04-23 21:14:56 UTC (rev 183209)
@@ -1,3 +1,19 @@
+2015-04-22  Alexey Proskuryakov  <[email protected]>
+
+        [iOS] WebKit services should inherit environment variables for home
+        https://bugs.webkit.org/show_bug.cgi?id=144078
+        rdar://problem/20571678
+
+        Reviewed by Dan Bernstein.
+
+        Pass current environment variables as XPC bootstrap. Also while at it, made
+        _CFBundleSetupXPCBootstrap not soft linked.
+
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm:
+        (main):
+        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+        (WebKit::connectToService):
+
 2015-04-23  Enrica Casucci  <[email protected]>
 
         Support share button.

Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm (183208 => 183209)


--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm	2015-04-23 21:03:46 UTC (rev 183208)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm	2015-04-23 21:14:56 UTC (rev 183209)
@@ -77,6 +77,15 @@
 
 int main(int argc, char** argv)
 {
+#if PLATFORM(IOS)
+    auto bootstrap = adoptOSObject(xpc_copy_bootstrap());
+    auto containerEnvironmentVariables = xpc_dictionary_get_value(bootstrap.get(), "ContainerEnvironmentVariables");
+    xpc_dictionary_apply(containerEnvironmentVariables, ^(const char *key, xpc_object_t value) {
+        setenv(key, xpc_string_get_string_ptr(value), 1);
+        return true;
+    });
+#endif
+
     xpc_main(XPCServiceEventHandler);
     return 0;
 }

Modified: trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm (183208 => 183209)


--- trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm	2015-04-23 21:03:46 UTC (rev 183208)
+++ trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm	2015-04-23 21:14:56 UTC (rev 183209)
@@ -28,6 +28,7 @@
 
 #import "DynamicLinkerEnvironmentExtractor.h"
 #import "EnvironmentVariables.h"
+#import <WebCore/CFBundleSPI.h>
 #import <WebCore/ServersSPI.h>
 #import <WebCore/SoftLinking.h>
 #import <WebCore/WebCoreNSStringExtras.h>
@@ -45,12 +46,6 @@
 #import <wtf/text/CString.h>
 #import <wtf/text/WTFString.h>
 
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
-// FIXME: Soft linking is temporary, make this into a regular function call once this function is available everywhere we need.
-SOFT_LINK_FRAMEWORK(CoreFoundation)
-SOFT_LINK_OPTIONAL(CoreFoundation, _CFBundleSetupXPCBootstrap, void, unused, (xpc_object_t))
-#endif
-
 namespace WebKit {
 
 namespace {
@@ -222,12 +217,21 @@
     // 1. When the application and system frameworks simply have different localized resources available, we should match the application.
     // 1.1. An important case is WebKitTestRunner, where we should use English localizations for all system frameworks.
     // 2. When AppleLanguages is passed as command line argument for UI process, or set in its preferences, we should respect it in child processes.
-    if (_CFBundleSetupXPCBootstrapPtr()) {
-        auto initializationMessage = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
-        _CFBundleSetupXPCBootstrapPtr()(initializationMessage.get());
-        xpc_connection_set_bootstrap(connection.get(), initializationMessage.get());
-    }
+    auto initializationMessage = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
+    _CFBundleSetupXPCBootstrap(initializationMessage.get());
+#if PLATFORM(IOS)
+    // Clients that set these environment variables explicitly do not have the values automatically forwarded by libxpc.
+    auto containerEnvironmentVariables = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
+    if (const char* environmentHOME = getenv("HOME"))
+        xpc_dictionary_set_string(containerEnvironmentVariables.get(), "HOME", environmentHOME);
+    if (const char* environmentCFFIXED_USER_HOME = getenv("CFFIXED_USER_HOME"))
+        xpc_dictionary_set_string(containerEnvironmentVariables.get(), "CFFIXED_USER_HOME", environmentCFFIXED_USER_HOME);
+    if (const char* environmentTMPDIR = getenv("TMPDIR"))
+        xpc_dictionary_set_string(containerEnvironmentVariables.get(), "TMPDIR", environmentTMPDIR);
+    xpc_dictionary_set_value(initializationMessage.get(), "ContainerEnvironmentVariables", containerEnvironmentVariables.get());
 #endif
+    xpc_connection_set_bootstrap(connection.get(), initializationMessage.get());
+#endif
 
     // XPC requires having an event handler, even if it is not used.
     xpc_connection_set_event_handler(connection.get(), ^(xpc_object_t event) { });
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to