<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[169457] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/169457">169457</a></dd>
<dt>Author</dt> <dd>ap@apple.com</dd>
<dt>Date</dt> <dd>2014-05-29 11:24:43 -0700 (Thu, 29 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Mac] Always use plug-in sandbox with sandboxed clients
https://bugs.webkit.org/show_bug.cgi?id=133358
&lt;rdar://problem/15637695&gt;

Reviewed by Anders Carlsson.

* PluginProcess/mac/PluginProcessMac.mm: (WebKit::PluginProcess::initializeSandbox):
Refuse to start if parent process is sandboxed, and plug-in process is not going to be.
None of this should run in normal case, because there are also checks on UI process side.
        
* Shared/Plugins/PluginModuleInfo.h:
* Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
(WebKit::NetscapePluginModule::getPluginInfo):
Added a member to PluginModuleInfo, telling whether the plug-in has a sandbox profile.

* Shared/Plugins/Netscape/mac/PluginInformationMac.mm:
(WebKit::getPlatformPluginModuleInformation): Use the new PluginModuleInfo member,
we no longer need to check the file system here.

* WebKit2.xcodeproj/project.pbxproj:
* Shared/mac/SandboxUtilities.h: Added.
* Shared/mac/SandboxUtilities.cpp: Added. (WebKit::processIsSandboxed):
This code is simple, but include magic is not. Moved it to a separate file to
avoid repeating.

* UIProcess/API/C/mac/WKContextPrivateMac.mm: Removed an unused include.

* UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
(WebKit::PluginInfoStore::shouldUsePlugin): Don't use unsandboxed plug-ins in
sandboxed applications.

* UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
(WebKit::PluginProcessProxy::platformGetLaunchOptions): Don't ever pass disable-sandbox
from sandboxed processes.

* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
(WebKit::XPCServiceInitializerDelegate::isClientSandboxed):
Use the new shared code in SandboxUtilities.h.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PluginProcessmacPluginProcessMacmm">trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointmm">trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedPluginsNetscapemacNetscapePluginModuleMacmm">trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedPluginsNetscapemacPluginInformationMacmm">trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/PluginInformationMac.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedPluginsPluginModuleInfoh">trunk/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICmacWKContextPrivateMacmm">trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPluginsmacPluginInfoStoreMacmm">trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPluginsmacPluginProcessProxyMacmm">trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2SharedmacSandboxUtilitiescpp">trunk/Source/WebKit2/Shared/mac/SandboxUtilities.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedmacSandboxUtilitiesh">trunk/Source/WebKit2/Shared/mac/SandboxUtilities.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/ChangeLog        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2014-05-29  Alexey Proskuryakov  &lt;ap@apple.com&gt;
+
+        [Mac] Always use plug-in sandbox with sandboxed clients
+        https://bugs.webkit.org/show_bug.cgi?id=133358
+        &lt;rdar://problem/15637695&gt;
+
+        Reviewed by Anders Carlsson.
+
+        * PluginProcess/mac/PluginProcessMac.mm: (WebKit::PluginProcess::initializeSandbox):
+        Refuse to start if parent process is sandboxed, and plug-in process is not going to be.
+        None of this should run in normal case, because there are also checks on UI process side.
+        
+        * Shared/Plugins/PluginModuleInfo.h:
+        * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
+        (WebKit::NetscapePluginModule::getPluginInfo):
+        Added a member to PluginModuleInfo, telling whether the plug-in has a sandbox profile.
+
+        * Shared/Plugins/Netscape/mac/PluginInformationMac.mm:
+        (WebKit::getPlatformPluginModuleInformation): Use the new PluginModuleInfo member,
+        we no longer need to check the file system here.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        * Shared/mac/SandboxUtilities.h: Added.
+        * Shared/mac/SandboxUtilities.cpp: Added. (WebKit::processIsSandboxed):
+        This code is simple, but include magic is not. Moved it to a separate file to
+        avoid repeating.
+
+        * UIProcess/API/C/mac/WKContextPrivateMac.mm: Removed an unused include.
+
+        * UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
+        (WebKit::PluginInfoStore::shouldUsePlugin): Don't use unsandboxed plug-ins in
+        sandboxed applications.
+
+        * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
+        (WebKit::PluginProcessProxy::platformGetLaunchOptions): Don't ever pass disable-sandbox
+        from sandboxed processes.
+
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
+        (WebKit::XPCServiceInitializerDelegate::isClientSandboxed):
+        Use the new shared code in SandboxUtilities.h.
+
</ins><span class="cx"> 2014-05-29  Timothy Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Crash loading skydrive.com (assertion under RemoteLayerTreeDisplayRefreshMonitor)
</span></span></pre></div>
<a id="trunkSourceWebKit2PluginProcessmacPluginProcessMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #import &quot;PluginProcessShim.h&quot;
</span><span class="cx"> #import &quot;PluginSandboxProfile.h&quot;
</span><span class="cx"> #import &quot;SandboxInitializationParameters.h&quot;
</span><ins>+#import &quot;SandboxUtilities.h&quot;
</ins><span class="cx"> #import &lt;CoreAudio/AudioHardware.h&gt;
</span><span class="cx"> #import &lt;WebCore/LocalizedStrings.h&gt;
</span><span class="cx"> #import &lt;WebKitSystemInterface.h&gt;
</span><span class="lines">@@ -456,12 +457,32 @@
</span><span class="cx"> 
</span><span class="cx"> void PluginProcess::initializeSandbox(const ChildProcessInitializationParameters&amp; parameters, SandboxInitializationParameters&amp; sandboxParameters)
</span><span class="cx"> {
</span><del>-    if (parameters.extraInitializationData.get(&quot;disable-sandbox&quot;) == &quot;1&quot;)
</del><ins>+    // PluginProcess may already be sandboxed if its parent process was sandboxed, and launched a child process instead of an XPC service.
+    // This is generally not expected, however we currently always spawn a child process to create a MIME type preferences file.
+    if (processIsSandboxed(getpid())) {
+        RELEASE_ASSERT(!parameters.connectionIdentifier.xpcConnection);
+        RELEASE_ASSERT(processIsSandboxed(getppid()));
</ins><span class="cx">         return;
</span><ins>+    }
</ins><span class="cx"> 
</span><ins>+    bool parentIsSandboxed = parameters.connectionIdentifier.xpcConnection &amp;&amp; processIsSandboxed(xpc_connection_get_pid(parameters.connectionIdentifier.xpcConnection.get()));
+
+    if (parameters.extraInitializationData.get(&quot;disable-sandbox&quot;) == &quot;1&quot;) {
+        if (parentIsSandboxed) {
+            WTFLogAlways(&quot;Sandboxed processes may not disable plug-in sandbox, terminating %s.&quot;, parameters.clientIdentifier.utf8().data());
+            exit(EX_OSERR);
+        }
+        return;
+    }
+
</ins><span class="cx">     String sandboxProfile = pluginSandboxProfile(m_pluginBundleIdentifier);
</span><del>-    if (sandboxProfile.isEmpty())
</del><ins>+    if (sandboxProfile.isEmpty()) {
+        if (parentIsSandboxed) {
+            WTFLogAlways(&quot;Sandboxed processes may only use sandboxed plug-ins, terminating %s.&quot;, parameters.clientIdentifier.utf8().data());
+            exit(EX_OSERR);
+        }
</ins><span class="cx">         return;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     sandboxParameters.setSandboxProfile(sandboxProfile);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #import &quot;config.h&quot;
</span><span class="cx"> 
</span><ins>+#import &quot;SandboxUtilities.h&quot;
</ins><span class="cx"> #import &quot;XPCServiceEntryPoint.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #if __has_include(&lt;xpc/private.h&gt;)
</span><span class="lines">@@ -34,16 +35,6 @@
</span><span class="cx"> extern &quot;C&quot; mach_port_t xpc_dictionary_copy_mach_send(xpc_object_t, const char*);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if __has_include(&lt;sandbox/private.h&gt;)
-#import &lt;sandbox/private.h&gt;
-#else
-enum sandbox_filter_type {
-    SANDBOX_FILTER_NONE,
-};
-extern &quot;C&quot;
-int sandbox_check(pid_t, const char *operation, enum sandbox_filter_type, ...);
-#endif
-
</del><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> XPCServiceInitializerDelegate::~XPCServiceInitializerDelegate()
</span><span class="lines">@@ -104,9 +95,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool XPCServiceInitializerDelegate::isClientSandboxed()
</span><span class="cx"> {
</span><del>-    pid_t clientPID = xpc_connection_get_pid(m_connection.get());
-
-    return sandbox_check(clientPID, nullptr, SANDBOX_FILTER_NONE);
</del><ins>+    return processIsSandboxed(xpc_connection_get_pid(m_connection.get()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedPluginsNetscapemacNetscapePluginModuleMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if ENABLE(NETSCAPE_PLUGIN_API)
</span><span class="cx"> 
</span><span class="cx"> #import &quot;PluginProcessProxy.h&quot;
</span><ins>+#import &quot;PluginSandboxProfile.h&quot;
</ins><span class="cx"> #import &lt;WebCore/WebCoreNSStringExtras.h&gt;
</span><span class="cx"> #import &lt;wtf/HashSet.h&gt;
</span><span class="cx"> #import &lt;wtf/MainThread.h&gt;
</span><span class="lines">@@ -386,7 +387,9 @@
</span><span class="cx">     if (!getPluginInfoFromPropertyLists(bundle.get(), plugin) &amp;&amp;
</span><span class="cx">         !getPluginInfoFromCarbonResources(bundle.get(), plugin))
</span><span class="cx">         return false;
</span><del>-    
</del><ins>+
+    plugin.hasSandboxProfile = pluginHasSandboxProfile(plugin.bundleIdentifier);
+
</ins><span class="cx">     RetainPtr&lt;CFStringRef&gt; filename = adoptCF(CFURLCopyLastPathComponent(bundleURL.get()));
</span><span class="cx">     plugin.info.file = filename.get();
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedPluginsNetscapemacPluginInformationMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/PluginInformationMac.mm (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/PluginInformationMac.mm        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/PluginInformationMac.mm        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -31,7 +31,6 @@
</span><span class="cx"> #import &quot;APINumber.h&quot;
</span><span class="cx"> #import &quot;APIString.h&quot;
</span><span class="cx"> #import &quot;PluginModuleInfo.h&quot;
</span><del>-#import &quot;PluginSandboxProfile.h&quot;
</del><span class="cx"> #import &quot;StringUtilities.h&quot;
</span><span class="cx"> #import &lt;WebKitSystemInterface.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -43,7 +42,7 @@
</span><span class="cx">     map.set(pluginInformationBundleVersionKey(), API::String::create(plugin.versionString));
</span><span class="cx">     map.set(pluginInformationBundleShortVersionKey(), API::String::create(plugin.shortVersionString));
</span><span class="cx">     map.set(pluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey(), API::Boolean::create(WKIsPluginUpdateAvailable(nsStringFromWebCoreString(plugin.bundleIdentifier))));
</span><del>-    map.set(pluginInformationHasSandboxProfileKey(), API::Boolean::create(pluginHasSandboxProfile(plugin.bundleIdentifier)));
</del><ins>+    map.set(pluginInformationHasSandboxProfileKey(), API::Boolean::create(plugin.hasSandboxProfile));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedPluginsPluginModuleInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/Shared/Plugins/PluginModuleInfo.h        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx">     String versionString;
</span><span class="cx">     String shortVersionString;
</span><span class="cx">     String preferencePanePath;
</span><ins>+    bool hasSandboxProfile;
</ins><span class="cx"> #elif PLATFORM(GTK)
</span><span class="cx">     bool requiresGtk2;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacSandboxUtilitiescpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/Shared/mac/SandboxUtilities.cpp (0 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/SandboxUtilities.cpp                                (rev 0)
+++ trunk/Source/WebKit2/Shared/mac/SandboxUtilities.cpp        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+/*
+ * Copyright (C) 2014 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;SandboxUtilities.h&quot;
+
+#if __has_include(&lt;sandbox/private.h&gt;)
+#import &lt;sandbox/private.h&gt;
+#else
+enum sandbox_filter_type {
+    SANDBOX_FILTER_NONE,
+};
+extern &quot;C&quot;
+int sandbox_check(pid_t, const char *operation, enum sandbox_filter_type, ...);
+#endif
+
+namespace WebKit {
+
+bool processIsSandboxed(pid_t pid)
+{
+    return sandbox_check(pid, nullptr, SANDBOX_FILTER_NONE);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2SharedmacSandboxUtilitiesh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/Shared/mac/SandboxUtilities.h (0 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/SandboxUtilities.h                                (rev 0)
+++ trunk/Source/WebKit2/Shared/mac/SandboxUtilities.h        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+/*
+ * Copyright (C) 2014 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. AND ITS CONTRIBUTORS ``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 ITS 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 SandboxUtilities_h
+#define SandboxUtilities_h
+
+#include &lt;sys/types.h&gt;
+
+namespace WebKit {
+
+bool processIsSandboxed(pid_t);
+
+}
+
+#endif // SandboxUtilities_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICmacWKContextPrivateMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -32,7 +32,6 @@
</span><span class="cx"> #import &quot;ImmutableDictionary.h&quot;
</span><span class="cx"> #import &quot;PluginInfoStore.h&quot;
</span><span class="cx"> #import &quot;PluginInformation.h&quot;
</span><del>-#import &quot;PluginSandboxProfile.h&quot;
</del><span class="cx"> #import &quot;StringUtilities.h&quot;
</span><span class="cx"> #import &quot;WKAPICast.h&quot;
</span><span class="cx"> #import &quot;WKPluginInformation.h&quot;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPluginsmacPluginInfoStoreMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -28,11 +28,14 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC) &amp;&amp; ENABLE(NETSCAPE_PLUGIN_API)
</span><span class="cx"> 
</span><ins>+#import &quot;Logging.h&quot;
</ins><span class="cx"> #import &quot;NetscapePluginModule.h&quot;
</span><ins>+#import &quot;SandboxUtilities.h&quot;
</ins><span class="cx"> #import &quot;WebKitSystemInterface.h&quot;
</span><span class="cx"> #import &lt;WebCore/WebCoreNSStringExtras.h&gt;
</span><span class="cx"> #import &lt;wtf/HashSet.h&gt;
</span><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><ins>+#import &lt;wtf/text/CString.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="lines">@@ -91,9 +94,16 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (plugin.bundleIdentifier == &quot;com.apple.java.JavaAppletPlugin&quot;)
</del><ins>+    if (plugin.bundleIdentifier == &quot;com.apple.java.JavaAppletPlugin&quot;) {
+        LOG(Plugins, &quot;Ignoring com.apple.java.JavaAppletPlugin&quot;);
</ins><span class="cx">         return false;
</span><ins>+    }
</ins><span class="cx"> 
</span><ins>+    if (processIsSandboxed(getpid()) &amp;&amp; !plugin.hasSandboxProfile) {
+        LOG(Plugins, &quot;Ignoring unsandboxed plug-in %s&quot;, plugin.bundleIdentifier.utf8().data());
+        return false;
+    }
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPluginsmacPluginProcessProxyMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #import &quot;EnvironmentVariables.h&quot;
</span><span class="cx"> #import &quot;PluginProcessCreationParameters.h&quot;
</span><span class="cx"> #import &quot;PluginProcessMessages.h&quot;
</span><ins>+#import &quot;SandboxUtilities.h&quot;
</ins><span class="cx"> #import &quot;WebKitSystemInterface.h&quot;
</span><span class="cx"> #import &lt;QuartzCore/CARemoteLayerServer.h&gt;
</span><span class="cx"> #import &lt;WebCore/FileSystem.h&gt;
</span><span class="lines">@@ -151,9 +152,12 @@
</span><span class="cx">     launchOptions.executableHeap = PluginProcessProxy::pluginNeedsExecutableHeap(pluginProcessAttributes.moduleInfo);
</span><span class="cx">     launchOptions.extraInitializationData.add(&quot;plugin-path&quot;, pluginProcessAttributes.moduleInfo.path);
</span><span class="cx"> 
</span><del>-    // FIXME: Don't allow this if the UI process is sandboxed.
-    if (pluginProcessAttributes.sandboxPolicy == PluginProcessSandboxPolicyUnsandboxed)
-        launchOptions.extraInitializationData.add(&quot;disable-sandbox&quot;, &quot;1&quot;);
</del><ins>+    if (pluginProcessAttributes.sandboxPolicy == PluginProcessSandboxPolicyUnsandboxed) {
+        if (!processIsSandboxed(getpid()))
+            launchOptions.extraInitializationData.add(&quot;disable-sandbox&quot;, &quot;1&quot;);
+        else
+            WTFLogAlways(&quot;Main process is sandboxed, ignoring plug-in sandbox policy&quot;);
+    }
</ins><span class="cx"> 
</span><span class="cx">     launchOptions.useXPC = shouldUseXPC(launchOptions, pluginProcessAttributes);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (169456 => 169457)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-05-29 18:19:03 UTC (rev 169456)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-05-29 18:24:43 UTC (rev 169457)
</span><span class="lines">@@ -1583,6 +1583,8 @@
</span><span class="cx">                 E18E6918169B667B009B6670 /* SecItemShimProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = E18E6914169B667B009B6670 /* SecItemShimProxyMessages.h */; };
</span><span class="cx">                 E19582D3153CBFD700B60875 /* PDFKitImports.h in Headers */ = {isa = PBXBuildFile; fileRef = E19582D2153CBFD700B60875 /* PDFKitImports.h */; };
</span><span class="cx">                 E19582D6153CC05400B60875 /* PDFKitImports.mm in Sources */ = {isa = PBXBuildFile; fileRef = E19582D4153CC05300B60875 /* PDFKitImports.mm */; };
</span><ins>+                E19BDA8A193686A400B97F57 /* SandboxUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = E19BDA88193686A400B97F57 /* SandboxUtilities.h */; };
+                E19BDA8B19368D4600B97F57 /* SandboxUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E19BDA87193686A400B97F57 /* SandboxUtilities.cpp */; };
</ins><span class="cx">                 E19BDA86193665E300B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = E19BDA8419365F4B00B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb */; };
</span><span class="cx">                 E1A31732134CEA6C007C9A4F /* AttributedString.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A31731134CEA6C007C9A4F /* AttributedString.h */; };
</span><span class="cx">                 E1A31735134CEA80007C9A4F /* AttributedString.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1A31734134CEA80007C9A4F /* AttributedString.mm */; };
</span><span class="lines">@@ -3634,6 +3636,8 @@
</span><span class="cx">                 E19582D2153CBFD700B60875 /* PDFKitImports.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PDFKitImports.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E19582D4153CC05300B60875 /* PDFKitImports.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PDFKitImports.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E1967E37150AB5E200C73169 /* com.apple.WebProcess.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.WebProcess.sb; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                E19BDA87193686A400B97F57 /* SandboxUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SandboxUtilities.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                E19BDA88193686A400B97F57 /* SandboxUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SandboxUtilities.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 E19BDA8419365F4B00B97F57 /* com.apple.appstore.CodeRedeemerNetscapePlugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.appstore.CodeRedeemerNetscapePlugin.sb; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E1A31731134CEA6C007C9A4F /* AttributedString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttributedString.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E1A31734134CEA80007C9A4F /* AttributedString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AttributedString.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5997,6 +6001,8 @@
</span><span class="cx">                                 1AAB4AA91296F1540023952F /* SandboxExtensionMac.mm */,
</span><span class="cx">                                 E1E552C216AE065E004ED653 /* SandboxInitialiationParametersMac.mm */,
</span><span class="cx">                                 51D1304F1382EAC000351EDD /* SecItemRequestData.cpp */,
</span><ins>+                                E19BDA87193686A400B97F57 /* SandboxUtilities.cpp */,
+                                E19BDA88193686A400B97F57 /* SandboxUtilities.h */,
</ins><span class="cx">                                 51D130501382EAC000351EDD /* SecItemRequestData.h */,
</span><span class="cx">                                 51D130511382EAC000351EDD /* SecItemResponseData.cpp */,
</span><span class="cx">                                 51D130521382EAC000351EDD /* SecItemResponseData.h */,
</span><span class="lines">@@ -6882,6 +6888,7 @@
</span><span class="cx">                         buildActionMask = 2147483647;
</span><span class="cx">                         files = (
</span><span class="cx">                                 1ADAE12E1919A5B400F48E21 /* WKPreferences.h in Headers */,
</span><ins>+                                E19BDA8A193686A400B97F57 /* SandboxUtilities.h in Headers */,
</ins><span class="cx">                         );
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span><span class="lines">@@ -8698,6 +8705,7 @@
</span><span class="cx">                                 2DA944951884E3B500ED86DB /* WKViewIOS.mm in Sources */,
</span><span class="cx">                                 BC14DF78120B5B7900826C0C /* InjectedBundleScriptWorld.cpp in Sources */,
</span><span class="cx">                                 1AE49A4A11FFA8CE0048B464 /* JSNPMethod.cpp in Sources */,
</span><ins>+                                E19BDA8B19368D4600B97F57 /* SandboxUtilities.cpp in Sources */,
</ins><span class="cx">                                 2D6AB542192B1C4A003A9FD1 /* WKPDFPageNumberIndicator.mm in Sources */,
</span><span class="cx">                                 1AE4987911FF7FAA0048B464 /* JSNPObject.cpp in Sources */,
</span><span class="cx">                                 BCE0937714FB128C001138D9 /* LayerHostingContext.mm in Sources */,
</span></span></pre>
</div>
</div>

</body>
</html>