Bug 136473 - Avoid warning if a process does not have access to com.apple.webinspector
Summary: Avoid warning if a process does not have access to com.apple.webinspector
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-09-02 18:34 PDT by Joseph Pecoraro
Modified: 2014-09-03 15:50 PDT (History)
6 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (2.16 KB, patch)
2014-09-02 18:35 PDT, Joseph Pecoraro
ap: review+
Details | Formatted Diff | Diff
[PATCH] For Landing (2.38 KB, patch)
2014-09-03 15:08 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2014-09-02 18:34:11 PDT
Some sandboxed processes will warn that they do not have access to the com.apple.webinspector mach port. Applications will automatically get the JavaScriptCore framework sandbox extensions to access the port but it seems some processes don't. In such cases the sandbox warning in syslog can be avoided because it is just noise.

<rdar://problem/16647344>
Comment 1 Joseph Pecoraro 2014-09-02 18:35:57 PDT
Created attachment 237539 [details]
[PATCH] Proposed Fix

Still don't know how I feel about this but here is the patch.
Comment 2 WebKit Commit Bot 2014-09-02 18:37:29 PDT
Attachment 237539 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/inspector/remote/RemoteInspector.mm:69:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Alexey Proskuryakov 2014-09-02 18:54:43 PDT
Comment on attachment 237539 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=237539&action=review

> Source/JavaScriptCore/inspector/remote/RemoteInspector.mm:59
> +#if __has_include(<sandbox/private.h>)
> +#import <sandbox/private.h>
> +#else
> +enum sandbox_filter_type {
> +    SANDBOX_FILTER_GLOBAL_NAME,
> +};
> +extern "C" {
> +int sandbox_check(pid_t, const char *operation, enum sandbox_filter_type, ...);
> +}
> +#endif

Sandbox SPIs seem like a prime target for the new technique Maciej is suggesting, as we use them in many places. Instead of declaring the SPIs in each .mm file, they would go into SandboxSPI.h.

In any case, sandbox_check declaration should not be inside the #else.
Comment 4 Joseph Pecoraro 2014-09-03 11:16:48 PDT
(In reply to comment #3)
> (From update of attachment 237539 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=237539&action=review
> 
> > Source/JavaScriptCore/inspector/remote/RemoteInspector.mm:59
> > +#if __has_include(<sandbox/private.h>)
> > +#import <sandbox/private.h>
> > +#else
> > +enum sandbox_filter_type {
> > +    SANDBOX_FILTER_GLOBAL_NAME,
> > +};
> > +extern "C" {
> > +int sandbox_check(pid_t, const char *operation, enum sandbox_filter_type, ...);
> > +}
> > +#endif
> 
> Sandbox SPIs seem like a prime target for the new technique Maciej is suggesting, as we use them in many places. Instead of declaring the SPIs in each .mm file, they would go into SandboxSPI.h.

I suppose I could. This would be the first in JavaScriptCore so I opted for the easier path.

> In any case, sandbox_check declaration should not be inside the #else.

I don't follow. Why not?
Comment 5 Alexey Proskuryakov 2014-09-03 11:27:00 PDT
> > In any case, sandbox_check declaration should not be inside the #else.
> 
> I don't follow. Why not?

This way, we'll get a compile error internally if the function signature changes in the future. That's much better than having to chase a mysterious behavior difference between internal and open source builds.
Comment 6 Joseph Pecoraro 2014-09-03 11:43:28 PDT
(In reply to comment #5)
> > > In any case, sandbox_check declaration should not be inside the #else.
> > 
> > I don't follow. Why not?
> 
> This way, we'll get a compile error internally if the function signature changes in the future. That's much better than having to chase a mysterious behavior difference between internal and open source builds.

Internally we should just get the include, so if the signature changes we would fail immediately. If the file changes, then we'd be out of luck.

    #if __has_include(<sandbox/private.h>)
    #import <sandbox/private.h>
    ...

I think we have to put some signature in the else, so that open source developers can compile the file. This pattern is repeated in a couple places (WebKit2).
Comment 7 Alexey Proskuryakov 2014-09-03 12:05:22 PDT
> if the signature changes we would fail immediately

This depends on how the signature changes - it can be source compatible, but not binary compatible. Having an unconditional declaration after the conditional include would catch that.
Comment 8 Joseph Pecoraro 2014-09-03 15:08:27 PDT
Created attachment 237587 [details]
[PATCH] For Landing
Comment 9 WebKit Commit Bot 2014-09-03 15:50:26 PDT
Comment on attachment 237587 [details]
[PATCH] For Landing

Clearing flags on attachment: 237587

Committed r173238: <http://trac.webkit.org/changeset/173238>
Comment 10 WebKit Commit Bot 2014-09-03 15:50:29 PDT
All reviewed patches have been landed.  Closing bug.