Changeset 183209 in webkit


Ignore:
Timestamp:
Apr 23, 2015, 2:14:56 PM (10 years ago)
Author:
ap@apple.com
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.
Location:
trunk/Source
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r183190 r183209  
     12015-04-23  Alexey Proskuryakov  <ap@apple.com>
     2
     3        [iOS] WebKit services should inherit environment variables for home
     4        https://bugs.webkit.org/show_bug.cgi?id=144078
     5        rdar://problem/20571678
     6
     7        Reviewed by Dan Bernstein.
     8
     9        * wtf/spi/darwin/XPCSPI.h: Added xpc_copy_bootstrap and xpc_dictionary_apply.
     10
    1112015-04-23  Alexey Proskuryakov  <ap@apple.com>
    212
  • trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h

    r183126 r183209  
    5959#if COMPILER_SUPPORTS(BLOCKS)
    6060typedef bool (^xpc_array_applier_t)(size_t index, xpc_object_t);
     61typedef bool (^xpc_dictionary_applier_t)(const char *key, xpc_object_t value);
    6162typedef void (^xpc_handler_t)(xpc_object_t);
    6263#endif
     
    99100#if COMPILER_SUPPORTS(BLOCKS)
    100101EXTERN_C bool xpc_array_apply(xpc_object_t, xpc_array_applier_t);
     102EXTERN_C bool xpc_dictionary_apply(xpc_object_t xdict, xpc_dictionary_applier_t applier);
    101103#endif
    102104EXTERN_C size_t xpc_array_get_count(xpc_object_t);
     
    143145#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    144146EXTERN_C void xpc_connection_set_bootstrap(xpc_connection_t, xpc_object_t bootstrap);
     147EXTERN_C xpc_object_t xpc_copy_bootstrap(void);
    145148#endif
    146149
  • trunk/Source/WebCore/ChangeLog

    r183204 r183209  
     12015-04-22  Alexey Proskuryakov  <ap@apple.com>
     2
     3        [iOS] WebKit services should inherit environment variables for home
     4        https://bugs.webkit.org/show_bug.cgi?id=144078
     5        rdar://problem/20571678
     6
     7        Reviewed by Dan Bernstein.
     8
     9        Added an SPI header for a drive-by fix.
     10
     11        * WebCore.xcodeproj/project.pbxproj:
     12        * platform/spi/cf/CFBundleSPI.h: Added.
     13
    1142015-04-23  Alex Christensen  <achristensen@webkit.org>
    215
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r183195 r183209  
    59995999                E107400D0E77BDC00033AF24 /* JSMessageChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E107400B0E77BDC00033AF24 /* JSMessageChannel.cpp */; };
    60006000                E107400E0E77BDC00033AF24 /* JSMessageChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = E107400C0E77BDC00033AF24 /* JSMessageChannel.h */; };
     6001                E10A39E21AE84E7100A29AE3 /* CFBundleSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = E10A39E11AE84E7100A29AE3 /* CFBundleSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
    60016002                E10B937C0B73C00A003ED890 /* JSCustomXPathNSResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = E10B937B0B73C00A003ED890 /* JSCustomXPathNSResolver.h */; };
    60026003                E10B93C30B73C291003ED890 /* JSCustomXPathNSResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E10B93C20B73C291003ED890 /* JSCustomXPathNSResolver.cpp */; };
     
    1360513606                E107400B0E77BDC00033AF24 /* JSMessageChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMessageChannel.cpp; sourceTree = "<group>"; };
    1360613607                E107400C0E77BDC00033AF24 /* JSMessageChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMessageChannel.h; sourceTree = "<group>"; };
     13608                E10A39E11AE84E7100A29AE3 /* CFBundleSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFBundleSPI.h; sourceTree = "<group>"; };
    1360713609                E10B937B0B73C00A003ED890 /* JSCustomXPathNSResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomXPathNSResolver.h; sourceTree = "<group>"; };
    1360813610                E10B93C20B73C291003ED890 /* JSCustomXPathNSResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomXPathNSResolver.cpp; sourceTree = "<group>"; };
     
    1649216494                        isa = PBXGroup;
    1649316495                        children = (
     16496                                E10A39E11AE84E7100A29AE3 /* CFBundleSPI.h */,
    1649416497                                65086DA719AC1719009AF46B /* CFLocaleSPI.h */,
    1649516498                                CE8245EF19B671BA00AC0122 /* CFNetworkConnectionCacheSPI.h */,
     
    2715627159                                416E29A6102FA962007FC14E /* WorkerReportingProxy.h in Headers */,
    2715727160                                2E4346530F546A8200B0F1BA /* WorkerRunLoop.h in Headers */,
     27161                                E10A39E21AE84E7100A29AE3 /* CFBundleSPI.h in Headers */,
    2715827162                                F3820899147D35F90010BC06 /* WorkerRuntimeAgent.h in Headers */,
    2715927163                                E1A643F20EC0972500779668 /* WorkerScriptController.h in Headers */,
  • trunk/Source/WebKit2/ChangeLog

    r183208 r183209  
     12015-04-22  Alexey Proskuryakov  <ap@apple.com>
     2
     3        [iOS] WebKit services should inherit environment variables for home
     4        https://bugs.webkit.org/show_bug.cgi?id=144078
     5        rdar://problem/20571678
     6
     7        Reviewed by Dan Bernstein.
     8
     9        Pass current environment variables as XPC bootstrap. Also while at it, made
     10        _CFBundleSetupXPCBootstrap not soft linked.
     11
     12        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm:
     13        (main):
     14        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
     15        (WebKit::connectToService):
     16
    1172015-04-23  Enrica Casucci  <enrica@apple.com>
    218
  • trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm

    r174220 r183209  
    7878int main(int argc, char** argv)
    7979{
     80#if PLATFORM(IOS)
     81    auto bootstrap = adoptOSObject(xpc_copy_bootstrap());
     82    auto containerEnvironmentVariables = xpc_dictionary_get_value(bootstrap.get(), "ContainerEnvironmentVariables");
     83    xpc_dictionary_apply(containerEnvironmentVariables, ^(const char *key, xpc_object_t value) {
     84        setenv(key, xpc_string_get_string_ptr(value), 1);
     85        return true;
     86    });
     87#endif
     88
    8089    xpc_main(XPCServiceEventHandler);
    8190    return 0;
  • trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm

    r179732 r183209  
    2929#import "DynamicLinkerEnvironmentExtractor.h"
    3030#import "EnvironmentVariables.h"
     31#import <WebCore/CFBundleSPI.h>
    3132#import <WebCore/ServersSPI.h>
    3233#import <WebCore/SoftLinking.h>
     
    4647#import <wtf/text/WTFString.h>
    4748
    48 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    49 // FIXME: Soft linking is temporary, make this into a regular function call once this function is available everywhere we need.
    50 SOFT_LINK_FRAMEWORK(CoreFoundation)
    51 SOFT_LINK_OPTIONAL(CoreFoundation, _CFBundleSetupXPCBootstrap, void, unused, (xpc_object_t))
    52 #endif
    53 
    5449namespace WebKit {
    5550
     
    223218    // 1.1. An important case is WebKitTestRunner, where we should use English localizations for all system frameworks.
    224219    // 2. When AppleLanguages is passed as command line argument for UI process, or set in its preferences, we should respect it in child processes.
    225     if (_CFBundleSetupXPCBootstrapPtr()) {
    226         auto initializationMessage = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
    227         _CFBundleSetupXPCBootstrapPtr()(initializationMessage.get());
    228         xpc_connection_set_bootstrap(connection.get(), initializationMessage.get());
    229     }
     220    auto initializationMessage = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
     221    _CFBundleSetupXPCBootstrap(initializationMessage.get());
     222#if PLATFORM(IOS)
     223    // Clients that set these environment variables explicitly do not have the values automatically forwarded by libxpc.
     224    auto containerEnvironmentVariables = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
     225    if (const char* environmentHOME = getenv("HOME"))
     226        xpc_dictionary_set_string(containerEnvironmentVariables.get(), "HOME", environmentHOME);
     227    if (const char* environmentCFFIXED_USER_HOME = getenv("CFFIXED_USER_HOME"))
     228        xpc_dictionary_set_string(containerEnvironmentVariables.get(), "CFFIXED_USER_HOME", environmentCFFIXED_USER_HOME);
     229    if (const char* environmentTMPDIR = getenv("TMPDIR"))
     230        xpc_dictionary_set_string(containerEnvironmentVariables.get(), "TMPDIR", environmentTMPDIR);
     231    xpc_dictionary_set_value(initializationMessage.get(), "ContainerEnvironmentVariables", containerEnvironmentVariables.get());
     232#endif
     233    xpc_connection_set_bootstrap(connection.get(), initializationMessage.get());
    230234#endif
    231235
Note: See TracChangeset for help on using the changeset viewer.