Bug 216834

Summary: [macOS] Issue sandbox extension for the diagnostic daemon
Product: WebKit Reporter: Per Arne Vollan <pvollan>
Component: WebKit Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, mitz, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
bfulgham: review+
Patch
none
Patch
none
Patch
none
Patch none

Description Per Arne Vollan 2020-09-22 10:19:39 PDT
On internal installs, the UI process should issue a mach lookup sandbox extension for accessing the diagnostic daemon, and send it to the WebContent process.
Comment 1 Per Arne Vollan 2020-09-22 10:21:42 PDT
<rdar://problem/58496834>
Comment 2 Per Arne Vollan 2020-09-22 11:39:21 PDT
Created attachment 409383 [details]
Patch
Comment 3 Per Arne Vollan 2020-09-22 11:42:33 PDT
*** Bug 206115 has been marked as a duplicate of this bug. ***
Comment 4 Per Arne Vollan 2020-09-22 11:45:39 PDT
Created attachment 409385 [details]
Patch
Comment 5 Brent Fulgham 2020-09-23 11:29:54 PDT
Comment on attachment 409385 [details]
Patch

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

r=me, but I think you could use an existing FileSystem function instead of the raw 'stat' operation.

> Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:68
> +#import <sys/stat.h>

You don't need to include this if you use , FileSystem::fileIsDirectory

> Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:211
> +    static bool isInternal = !stat("/AppleInternal", &st);

I think it might be better to do:

static bool isInternal = FileSystem::fileIsDirectory("/AppleInternal", FileSystem::ShouldFollowSymbolicLinks::No);
Comment 6 Per Arne Vollan 2020-09-23 11:40:19 PDT
Created attachment 409488 [details]
Patch
Comment 7 Per Arne Vollan 2020-09-23 11:40:56 PDT
(In reply to Brent Fulgham from comment #5)
> Comment on attachment 409385 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=409385&action=review
> 
> r=me, but I think you could use an existing FileSystem function instead of
> the raw 'stat' operation.
> 
> > Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:68
> > +#import <sys/stat.h>
> 
> You don't need to include this if you use , FileSystem::fileIsDirectory
> 
> > Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:211
> > +    static bool isInternal = !stat("/AppleInternal", &st);
> 
> I think it might be better to do:
> 
> static bool isInternal = FileSystem::fileIsDirectory("/AppleInternal",
> FileSystem::ShouldFollowSymbolicLinks::No);

Will fix, thanks for reviewing!
Comment 8 Per Arne Vollan 2020-09-23 11:45:42 PDT
Created attachment 409489 [details]
Patch
Comment 9 EWS 2020-09-23 12:52:08 PDT
Committed r267498: <https://trac.webkit.org/changeset/267498>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 409489 [details].
Comment 10 mitz 2020-09-23 13:53:33 PDT
Comment on attachment 409385 [details]
Patch

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

>> Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:211
>> +    static bool isInternal = !stat("/AppleInternal", &st);
> 
> I think it might be better to do:
> 
> static bool isInternal = FileSystem::fileIsDirectory("/AppleInternal", FileSystem::ShouldFollowSymbolicLinks::No);

Either way it’s not the recommended way to test whether a computer is running the Apple-internal version of macOS. See OSVariantSPI.h in WTF.
Comment 11 Per Arne Vollan 2020-09-23 15:19:59 PDT
(In reply to mitz from comment #10)
> Comment on attachment 409385 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=409385&action=review
> 
> >> Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:211
> >> +    static bool isInternal = !stat("/AppleInternal", &st);
> > 
> > I think it might be better to do:
> > 
> > static bool isInternal = FileSystem::fileIsDirectory("/AppleInternal", FileSystem::ShouldFollowSymbolicLinks::No);
> 
> Either way it’s not the recommended way to test whether a computer is
> running the Apple-internal version of macOS. See OSVariantSPI.h in WTF.

Ah, thanks! I will look into that.
Comment 12 Per Arne Vollan 2020-09-24 09:46:24 PDT
Created attachment 409584 [details]
Patch
Comment 13 Per Arne Vollan 2020-09-24 09:47:41 PDT
Created attachment 409585 [details]
Patch