Title: [254052] trunk
Revision
254052
Author
pvol...@apple.com
Date
2020-01-06 08:03:44 -0800 (Mon, 06 Jan 2020)

Log Message

[iOS] Issue mach lookup extension to launch services daemon for Mail
https://bugs.webkit.org/show_bug.cgi?id=205316

Reviewed by Brent Fulgham.

Source/WebCore:

Export function getting bundle identifier.

Test: fast/sandbox/ios/sandbox-mach-lookup-mail.html

* platform/RuntimeApplicationChecks.h:

Source/WebKit:

Issue mach lookup extension to "com.apple.lsd.open" for Mail, since this service will be removed from the WebContent sandbox.

Test: fast/sandbox/ios/sandbox-mach-lookup-mail.html

* Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
* UIProcess/API/Cocoa/WKWebViewTesting.mm:
(+[WKWebView _setApplicationBundleIdentifier:]):
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
(WebKit::WebProcessPool::platformInitializeNetworkProcess):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):

Tools:

Add test option to set bundle identifier. Using this, WebKitTestRunner can pretend to be any client, e.g. Mail.

Test: fast/sandbox/ios/sandbox-mach-lookup-mail.html

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createWebViewWithOptions):
(WTR::updateTestOptionsFromTestHeader):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::setApplicationBundleIdentifier):

LayoutTests:

* fast/sandbox/ios/sandbox-mach-lookup-mail-expected.txt: Added.
* fast/sandbox/ios/sandbox-mach-lookup-mail.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (254051 => 254052)


--- trunk/LayoutTests/ChangeLog	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/LayoutTests/ChangeLog	2020-01-06 16:03:44 UTC (rev 254052)
@@ -1,3 +1,13 @@
+2020-01-06  Per Arne Vollan  <pvol...@apple.com>
+
+        [iOS] Issue mach lookup extension to launch services daemon for Mail
+        https://bugs.webkit.org/show_bug.cgi?id=205316
+
+        Reviewed by Brent Fulgham.
+
+        * fast/sandbox/ios/sandbox-mach-lookup-mail-expected.txt: Added.
+        * fast/sandbox/ios/sandbox-mach-lookup-mail.html: Added.
+
 2020-01-05  Zalan Bujtas  <za...@apple.com>
 
         [SLL] Generate runs for preserved new lines

Added: trunk/LayoutTests/fast/sandbox/ios/sandbox-mach-lookup-mail-expected.txt (0 => 254052)


--- trunk/LayoutTests/fast/sandbox/ios/sandbox-mach-lookup-mail-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/sandbox/ios/sandbox-mach-lookup-mail-expected.txt	2020-01-06 16:03:44 UTC (rev 254052)
@@ -0,0 +1,7 @@
+Regression tests for mach lookup sandbox changes for Mail on iOS
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS internals.hasSandboxMachLookupAccessToGlobalName("com.apple.WebKit.WebContent", "com.apple.lsd.open") is true
+

Added: trunk/LayoutTests/fast/sandbox/ios/sandbox-mach-lookup-mail.html (0 => 254052)


--- trunk/LayoutTests/fast/sandbox/ios/sandbox-mach-lookup-mail.html	                        (rev 0)
+++ trunk/LayoutTests/fast/sandbox/ios/sandbox-mach-lookup-mail.html	2020-01-06 16:03:44 UTC (rev 254052)
@@ -0,0 +1,14 @@
+<!DOCTYPE html><!-- webkit-test-runner [ applicationBundleIdentifier=com.apple.mobilemail ] -->
+<html>
+<head>
+<script src=""
+<script>
+description('Regression tests for mach lookup sandbox changes for Mail on iOS');
+
+if (window.internals) {
+    shouldBeTrue("internals.hasSandboxMachLookupAccessToGlobalName(\"com.apple.WebKit.WebContent\", \"com.apple.lsd.open\")");
+}
+</script>
+</head>
+<body>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (254051 => 254052)


--- trunk/Source/WebCore/ChangeLog	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Source/WebCore/ChangeLog	2020-01-06 16:03:44 UTC (rev 254052)
@@ -1,3 +1,16 @@
+2020-01-06  Per Arne Vollan  <pvol...@apple.com>
+
+        [iOS] Issue mach lookup extension to launch services daemon for Mail
+        https://bugs.webkit.org/show_bug.cgi?id=205316
+
+        Reviewed by Brent Fulgham.
+
+        Export function getting bundle identifier.
+
+        Test: fast/sandbox/ios/sandbox-mach-lookup-mail.html
+
+        * platform/RuntimeApplicationChecks.h:
+
 2020-01-06  Youenn Fablet  <you...@apple.com>
 
         RemoteVideoSample::create does not need to take a MediaSample r value

Modified: trunk/Source/WebCore/platform/RuntimeApplicationChecks.h (254051 => 254052)


--- trunk/Source/WebCore/platform/RuntimeApplicationChecks.h	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Source/WebCore/platform/RuntimeApplicationChecks.h	2020-01-06 16:03:44 UTC (rev 254052)
@@ -47,7 +47,7 @@
 WEBCORE_EXPORT uint32_t applicationSDKVersion();
 
 WEBCORE_EXPORT void setApplicationBundleIdentifier(const String&);
-String applicationBundleIdentifier();
+WEBCORE_EXPORT String applicationBundleIdentifier();
 
 #if PLATFORM(MAC)
 

Modified: trunk/Source/WebKit/ChangeLog (254051 => 254052)


--- trunk/Source/WebKit/ChangeLog	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Source/WebKit/ChangeLog	2020-01-06 16:03:44 UTC (rev 254052)
@@ -1,3 +1,28 @@
+2020-01-06  Per Arne Vollan  <pvol...@apple.com>
+
+        [iOS] Issue mach lookup extension to launch services daemon for Mail
+        https://bugs.webkit.org/show_bug.cgi?id=205316
+
+        Reviewed by Brent Fulgham.
+
+        Issue mach lookup extension to "com.apple.lsd.open" for Mail, since this service will be removed from the WebContent sandbox.
+
+        Test: fast/sandbox/ios/sandbox-mach-lookup-mail.html
+
+        * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode const):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
+        * UIProcess/API/Cocoa/WKWebViewTesting.mm:
+        (+[WKWebView _setApplicationBundleIdentifier:]):
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeWebProcess):
+        (WebKit::WebProcessPool::platformInitializeNetworkProcess):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+
 2020-01-06  Youenn Fablet  <you...@apple.com>
 
         RemoteVideoSample::create does not need to take a MediaSample r value

Modified: trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb (254051 => 254052)


--- trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb	2020-01-06 16:03:44 UTC (rev 254052)
@@ -974,7 +974,7 @@
 (allow mach-lookup
     (require-all
         (extension "com.apple.webkit.extension.mach")
-        (global-name "com.apple.iphone.axserver-systemwide" "com.apple.tccd" "com.apple.nehelper" "com.apple.nesessionmanager.content-filter" "com.apple.uikit.viewservice.com.apple.WebContentFilter.remoteUI" "com.apple.diagnosticd")))
+        (global-name "com.apple.iphone.axserver-systemwide" "com.apple.tccd" "com.apple.nehelper" "com.apple.nesessionmanager.content-filter" "com.apple.uikit.viewservice.com.apple.WebContentFilter.remoteUI" "com.apple.diagnosticd" "com.apple.lsd.open")))
 
 (allow mach-lookup
     (require-all

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (254051 => 254052)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2020-01-06 16:03:44 UTC (rev 254052)
@@ -163,6 +163,7 @@
 #if PLATFORM(IOS)
     encoder << compilerServiceExtensionHandle;
     encoder << contentFilterExtensionHandle;
+    encoder << launchServicesOpenExtensionHandle;
     encoder << diagnosticsExtensionHandle;
 #endif
     
@@ -419,6 +420,12 @@
         return false;
     parameters.contentFilterExtensionHandle = WTFMove(*contentFilterExtensionHandle);
 
+    Optional<Optional<SandboxExtension::Handle>> launchServicesOpenExtensionHandle;
+    decoder >> launchServicesOpenExtensionHandle;
+    if (!launchServicesOpenExtensionHandle)
+        return false;
+    parameters.launchServicesOpenExtensionHandle = WTFMove(*launchServicesOpenExtensionHandle);
+
     Optional<Optional<SandboxExtension::Handle>> diagnosticsExtensionHandle;
     decoder >> diagnosticsExtensionHandle;
     if (!diagnosticsExtensionHandle)

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (254051 => 254052)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2020-01-06 16:03:44 UTC (rev 254052)
@@ -201,6 +201,7 @@
 #if PLATFORM(IOS)
     Optional<SandboxExtension::Handle> compilerServiceExtensionHandle;
     Optional<SandboxExtension::Handle> contentFilterExtensionHandle;
+    Optional<SandboxExtension::Handle> launchServicesOpenExtensionHandle;
     Optional<SandboxExtension::Handle> diagnosticsExtensionHandle;
 #endif
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h (254051 => 254052)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h	2020-01-06 16:03:44 UTC (rev 254052)
@@ -59,4 +59,6 @@
 @property (nonatomic, readonly) BOOL _hasServiceWorkerForegroundActivityForTesting;
 - (void)_setAssertionStateForTesting:(int)state;
 
++ (void)_setApplicationBundleIdentifier:(NSString *)bundleIdentifier;
+
 @end

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm (254051 => 254052)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm	2020-01-06 16:03:44 UTC (rev 254052)
@@ -202,4 +202,9 @@
 #endif
 }
 
++ (void)_setApplicationBundleIdentifier:(NSString *)bundleIdentifier
+{
+    WebCore::setApplicationBundleIdentifier(String(bundleIdentifier));
+}
+
 @end

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (254051 => 254052)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2020-01-06 16:03:44 UTC (rev 254052)
@@ -241,7 +241,7 @@
     parameters.uiProcessBundleResourcePath = m_resolvedPaths.uiProcessBundleResourcePath;
     SandboxExtension::createHandleWithoutResolvingPath(parameters.uiProcessBundleResourcePath, SandboxExtension::Type::ReadOnly, parameters.uiProcessBundleResourcePathExtensionHandle);
 
-    parameters.uiProcessBundleIdentifier = String([[NSBundle mainBundle] bundleIdentifier]);
+    parameters.uiProcessBundleIdentifier = applicationBundleIdentifier();
     parameters.uiProcessSDKVersion = dyld_get_program_sdk_version();
 
 #if PLATFORM(IOS_FAMILY)
@@ -315,6 +315,12 @@
         SandboxExtension::createHandleForMachLookup("com.apple.AGXCompilerService", WTF::nullopt, compilerServiceExtensionHandle);
         parameters.compilerServiceExtensionHandle = WTFMove(compilerServiceExtensionHandle);
     }
+
+    if (WebCore::IOSApplication::isMobileMail()) {
+        SandboxExtension::Handle launchServicesOpenExtensionHandle;
+        SandboxExtension::createHandleForMachLookup("com.apple.lsd.open", WTF::nullopt, launchServicesOpenExtensionHandle);
+        parameters.launchServicesOpenExtensionHandle = WTFMove(launchServicesOpenExtensionHandle);
+    }
     
     if (isInternalInstall()) {
         SandboxExtension::Handle diagnosticsExtensionHandle;
@@ -348,7 +354,7 @@
 
 void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationParameters& parameters)
 {
-    parameters.uiProcessBundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
+    parameters.uiProcessBundleIdentifier = applicationBundleIdentifier();
     parameters.uiProcessSDKVersion = dyld_get_program_sdk_version();
 
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (254051 => 254052)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-01-06 16:03:44 UTC (rev 254052)
@@ -241,6 +241,9 @@
     if (parameters.compilerServiceExtensionHandle)
         SandboxExtension::consumePermanently(*parameters.compilerServiceExtensionHandle);
 
+    if (parameters.launchServicesOpenExtensionHandle)
+        SandboxExtension::consumePermanently(*parameters.launchServicesOpenExtensionHandle);
+
     if (parameters.diagnosticsExtensionHandle)
         SandboxExtension::consumePermanently(*parameters.diagnosticsExtensionHandle);
 

Modified: trunk/Tools/ChangeLog (254051 => 254052)


--- trunk/Tools/ChangeLog	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Tools/ChangeLog	2020-01-06 16:03:44 UTC (rev 254052)
@@ -1,3 +1,23 @@
+2020-01-06  Per Arne Vollan  <pvol...@apple.com>
+
+        [iOS] Issue mach lookup extension to launch services daemon for Mail
+        https://bugs.webkit.org/show_bug.cgi?id=205316
+
+        Reviewed by Brent Fulgham.
+
+        Add test option to set bundle identifier. Using this, WebKitTestRunner can pretend to be any client, e.g. Mail.
+
+        Test: fast/sandbox/ios/sandbox-mach-lookup-mail.html
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::createWebViewWithOptions):
+        (WTR::updateTestOptionsFromTestHeader):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestOptions.h:
+        (WTR::TestOptions::hasSameInitializationOptions const):
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::setApplicationBundleIdentifier):
+
 2020-01-06  Philippe Normand  <pnorm...@igalia.com>
 
         [WPE][Qt] TestRunJavaScript failure

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (254051 => 254052)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2020-01-06 16:03:44 UTC (rev 254052)
@@ -622,6 +622,17 @@
 
 void TestController::createWebViewWithOptions(const TestOptions& options)
 {
+#if PLATFORM(COCOA)
+    if (m_hasSetApplicationBundleIdentifier) {
+        // Exit if the application bundle identifier has already been set, since it can only be set once.
+        exit(1);
+    }
+    if (!options.applicationBundleIdentifier.isEmpty()) {
+        setApplicationBundleIdentifier(options.applicationBundleIdentifier);
+        m_hasSetApplicationBundleIdentifier = true;
+    }
+#endif
+
     auto configuration = generatePageConfiguration(options);
 
     // Some preferences (notably mock scroll bars setting) currently cannot be re-applied to an existing view, so we need to set them now.
@@ -1449,6 +1460,8 @@
             testOptions.contextOptions.ignoreSynchronousMessagingTimeouts = parseBooleanTestHeaderValue(value);
         else if (key == "contentMode")
             testOptions.contentMode = { value.c_str() };
+        else if (key == "applicationBundleIdentifier")
+            testOptions.applicationBundleIdentifier = { value.c_str() };
         else if (key == "enableAppNap")
             testOptions.enableAppNap = parseBooleanTestHeaderValue(value);
         else if (key == "enableBackForwardCache")

Modified: trunk/Tools/WebKitTestRunner/TestController.h (254051 => 254052)


--- trunk/Tools/WebKitTestRunner/TestController.h	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2020-01-06 16:03:44 UTC (rev 254052)
@@ -362,6 +362,7 @@
 #if PLATFORM(COCOA)
     void cocoaPlatformInitialize();
     void cocoaResetStateToConsistentValues(const TestOptions&);
+    void setApplicationBundleIdentifier(const String&);
 #endif
     void platformConfigureViewForTest(const TestInvocation&);
     void platformWillRunTest(const TestInvocation&);
@@ -616,6 +617,10 @@
     bool m_allowsAnySSLCertificate { true };
     bool m_shouldSwapToEphemeralSessionOnNextNavigation { false };
     bool m_shouldSwapToDefaultSessionOnNextNavigation { false };
+    
+#if PLATFORM(COCOA)
+    bool m_hasSetApplicationBundleIdentifier { false };
+#endif
 };
 
 struct TestCommand {

Modified: trunk/Tools/WebKitTestRunner/TestOptions.h (254051 => 254052)


--- trunk/Tools/WebKitTestRunner/TestOptions.h	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Tools/WebKitTestRunner/TestOptions.h	2020-01-06 16:03:44 UTC (rev 254052)
@@ -109,7 +109,8 @@
     HashMap<String, bool> experimentalFeatures;
     HashMap<String, bool> internalDebugFeatures;
     String contentMode;
-
+    String applicationBundleIdentifier;
+    
     ContextOptions contextOptions;
 
     TestOptions(const std::string& pathOrURL);
@@ -155,6 +156,7 @@
             || shouldPresentPopovers != options.shouldPresentPopovers
             || contentInsetTop != options.contentInsetTop
             || contentMode != options.contentMode
+            || applicationBundleIdentifier != options.applicationBundleIdentifier
             || enableAppNap != options.enableAppNap
             || enableBackForwardCache != options.enableBackForwardCache
             || enableLazyImageLoading != options.enableLazyImageLoading

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (254051 => 254052)


--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2020-01-06 15:02:13 UTC (rev 254051)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2020-01-06 16:03:44 UTC (rev 254052)
@@ -250,6 +250,15 @@
     }
 }
 
+void TestController::setApplicationBundleIdentifier(const String& bundleIdentifier)
+{
+    if (bundleIdentifier.isEmpty())
+        return;
+    
+    auto applicationBundleIdentifier = adoptNS([NSString stringWithUTF8String:bundleIdentifier.utf8().data()]);
+    [TestRunnerWKWebView _setApplicationBundleIdentifier:applicationBundleIdentifier.get()];
+}
+
 void TestController::cocoaResetStateToConsistentValues(const TestOptions& options)
 {
     m_calendarSwizzler = nullptr;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to