Title: [173238] trunk/Source/_javascript_Core
Revision
173238
Author
[email protected]
Date
2014-09-03 15:50:17 -0700 (Wed, 03 Sep 2014)

Log Message

Avoid warning if a process does not have access to com.apple.webinspector
https://bugs.webkit.org/show_bug.cgi?id=136473

Patch by Joseph Pecoraro <[email protected]> on 2014-09-03
Reviewed by Alexey Proskuryakov.

Pre-check for access to the mach port to avoid emitting warnings
in syslog for processes that do not have access.

* inspector/remote/RemoteInspector.mm:
(Inspector::canAccessWebInspectorMachPort):
(Inspector::RemoteInspector::shared):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (173237 => 173238)


--- trunk/Source/_javascript_Core/ChangeLog	2014-09-03 22:44:34 UTC (rev 173237)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-09-03 22:50:17 UTC (rev 173238)
@@ -1,3 +1,17 @@
+2014-09-03  Joseph Pecoraro  <[email protected]>
+
+        Avoid warning if a process does not have access to com.apple.webinspector
+        https://bugs.webkit.org/show_bug.cgi?id=136473
+
+        Reviewed by Alexey Proskuryakov.
+
+        Pre-check for access to the mach port to avoid emitting warnings
+        in syslog for processes that do not have access.
+
+        * inspector/remote/RemoteInspector.mm:
+        (Inspector::canAccessWebInspectorMachPort):
+        (Inspector::RemoteInspector::shared):
+
 2014-09-03  Filip Pizlo  <[email protected]>
 
         Temporarily disable call edge profiling. It is causing crashes and I'm still investigating

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.mm (173237 => 173238)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.mm	2014-09-03 22:44:34 UTC (rev 173237)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.mm	2014-09-03 22:50:17 UTC (rev 173238)
@@ -40,12 +40,22 @@
 
 #if __has_include(<xpc/xpc.h>)
 #import <xpc/xpc.h>
-#else
+#endif
 extern "C" {
     xpc_connection_t xpc_connection_create_mach_service(const char* name, dispatch_queue_t, uint64_t flags);
     void xpc_release(xpc_object_t);
 }
+
+#if __has_include(<sandbox/private.h>)
+#import <sandbox/private.h>
+#else
+enum sandbox_filter_type {
+    SANDBOX_FILTER_GLOBAL_NAME,
+};
 #endif
+extern "C" {
+    int sandbox_check(pid_t, const char *operation, enum sandbox_filter_type, ...);
+}
 
 #if PLATFORM(IOS)
 #import <wtf/ios/WebCoreThread.h>
@@ -53,6 +63,11 @@
 
 namespace Inspector {
 
+static bool canAccessWebInspectorMachPort()
+{
+    return sandbox_check(getpid(), "mach-lookup", SANDBOX_FILTER_GLOBAL_NAME, WIRXPCMachPortName) == 0;
+}
+
 static void dispatchAsyncOnQueueSafeForAnyDebuggable(void (^block)())
 {
 #if PLATFORM(IOS)
@@ -78,9 +93,11 @@
 
     static dispatch_once_t once;
     dispatch_once(&once, ^{
-        JSC::initializeThreading();
-        if (RemoteInspector::startEnabled)
-            shared.get().start();
+        if (canAccessWebInspectorMachPort()) {
+            JSC::initializeThreading();
+            if (RemoteInspector::startEnabled)
+                shared.get().start();
+        }
     });
 
     return shared;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to