Date
1 - 15 of 15
Sandboxed WkWebView
Gerriet M. Denkmann
On 18 Oct 2017, at 12:21, Jens Alfke <jens@...> wrote:The reason that I took all this trouble with sandboxing is:On Oct 17, 2017, at 9:14 PM, Gerriet M. Denkmann <g@...> wrote:It sounds like the framework is being too eager to check for this entitlement. It’s definitely worth filing a bug report with Apple! In iOS 11 this shows a cat: htmlString = <h1>Cat</h1><img alt=“Cat” src=“cat.gif” /> [wkWebView loadHTMLString: htmlString baseURL: folder containing cat.gif ] In macOS 12.6 there was no cat, just a blue icon with “?”, probably meaning broken link. So I thought: iOS is sandboxed, so maybe WkWebView needs sandboxing to show cats. But now with sandboxing on macOS I still do not see a cat. Most frustrating. Gerriet. |
|
It sounds like the framework is being too eager to check for this entitlement. It’s definitely worth filing a bug report with Apple! —Jens |
|
Gerriet M. Denkmann
On 18 Oct 2017, at 06:21, Andrew Keller <andrew@...> wrote:I just tried this:That one by itself didn’t change the symptoms of the issue."deny mach-lookup com.apple.nsurlstorage-cache” sounds exactly like the OS denying something because the app isn’t provisioned for that capability, but I’m having trouble identifying which provision I need to turn on in Xcode.I believe URL access requires com.apple.security.files.bookmarks.app-scope entitlement in a sandboxed app. App Sandbox Network [checked] Outgoing Connections (Client) and now it seems to work. Excellent idea! I would never have guessed that an app which does not use any outgoing connections at all needs this entitlement. A million thanks to you! Gerriet. |
|
Gerriet M. Denkmann
On 17 Oct 2017, at 23:37, Andrew Keller <andrew@...> wrote:Regarding: fehler 10:19:55.449646 -0400 sandboxd Sandbox: SandboxedWebView(4372) deny mach-lookup com.apple.nsurlstorage-cache I added in: SandboxedWebView.enttitlements the following item: com.apple.security.temporary-exception.mach-lookup.global-name = com.apple.nsurlstorage-cache which seems to get rid of this error. But the app does not work any better for this. Regarding: fehler 10:19:55.417821 -0400 appleeventsd <rdar://problem/11489077> A sandboxed application with pid 4372, ‘“SandboxedWebView”’,…. This might go away if you run the app not from Xcode, but as /Applications/SandboxedWebView.app I tried this too, but no change for the better. Herzliche Grüße Gerriet.
|
|
Andrew Keller
That one by itself didn’t change the symptoms of the issue."deny mach-lookup com.apple.nsurlstorage-cache” sounds exactly like the OS denying something because the app isn’t provisioned for that capability, but I’m having trouble identifying which provision I need to turn on in Xcode.I believe URL access requires com.apple.security.files.bookmarks.app-scope entitlement in a sandboxed app. However, upon clicking on random buttons on the Entitlements screen, it seems that `com.apple.security.network.client` does make the example app work while sandboxed. I wonder if there is a more specific entitlement that may be more to-the-point, given that this test application does not need to make network calls. Thanks, - Andrew |
|
Marco S Hyman
"deny mach-lookup com.apple.nsurlstorage-cache” sounds exactly like the OS denying something because the app isn’t provisioned for that capability, but I’m having trouble identifying which provision I need to turn on in Xcode.I believe URL access requires com.apple.security.files.bookmarks.app-scope entitlement in a sandboxed app. Marc |
|
Yup. This doesn’t even require messing with symlinks; it’s a supported option in the GUI: - Open Users & Groups system pref - Unlock - Ctrl/right-click a user in the list - Select “Advanced Options” from the context menu - A sheet opens where you can configure the home directory path (and much more) —Jens |
|
Andrew Keller
Now I’m curious. I created the test application as described, and I get the same results (macOS 10.13, Xcode 9). I also see these entries in the system log while the app is sandboxed:
"deny mach-lookup com.apple.nsurlstorage-cache” sounds exactly like the OS denying something because the app isn’t provisioned for that capability, but I’m having trouble identifying which provision I need to turn on in Xcode. Any ideas? Thanks, - Andrew
|
|
Gerriet M. Denkmann
On 17 Oct 2017, at 10:59, Marco S Hyman <marc@...> wrote:My Test app is really simple, just one window (with WKWebView), one framework (WebKit.framework) and one method:This said, the porcupine in my home directory seems to be a red herring:I don’t know if this has anything to do with your issue. #import "AppDelegate.h" @import WebKit; @interface AppDelegate () @property (weak) IBOutlet NSWindow *window; @property (strong) IBOutlet WKWebView *webView; @end @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { BOOL sandboxed = ![ NSFileManager.defaultManager isWritableFileAtPath: @"/tmp/" ]; NSString *htmlString = sandboxed ? @"<h1>Sand</h1>" : @"<h1>Water</h1>"; NSLog(@"%s %@ will loadHTMLString: \"%@\" baseURL: nil",__FUNCTION__, self.webView, htmlString); WKNavigation *a = [ self.webView loadHTMLString: htmlString baseURL: nil ]; NSLog(@"%s loadHTMLString returned %@",__FUNCTION__, a); } @end No access to any files, whether inside or outside of home folder. Still I have never seen “Sand” in my window. Gerriet. |
|
Marco S Hyman
This said, the porcupine in my home directory seems to be a red herring:I don’t know if this has anything to do with your issue. One difference between a sandboxed and non-sandboxed app is that the “home directory” in a sandboxed app is inside the application container, not the current users home directory. ~/ ==> non-sandboxed home directory ~/Library/Containers/com.example.appid/Data/ ==> sandboxed home directory You will not be able to create/access anything outside of the sandbox container without going through Powerbox or adding appropriate entitlements. Marc |
|
Gerriet M. Denkmann
Some further notes:
toggle quoted message
Show quoted text
NSString *porcupine = @"เม่น"; NSData *utf8Data = [ porcupine dataUsingEncoding: NSUTF8StringEncoding ]; NSString *badPorcupine = [ [ NSString alloc ] initWithData: utf8Data encoding: NSASCIIStringEncoding ]; NSLog(@"NSASCIIStringEncoding \"%@\" → \"%@\"", porcupine, badPorcupine); prints: NSASCIIStringEncoding “เม่น" → "à¹à¸¡à¹à¸" Please note that the path to the home directory is *not* guaranteed to be Ascii: if anything in ”/Users/username” is a symbolic link then this assumption is no longer valid. NSLog(@"home \"%@\"", @"~".stringByExpandingTildeInPath); prints: home "/Volumes/เม่น/Users/gerriet/Library/Containers/de.mdenkmann.TestViewsMac/Data" This said, the porcupine in my home directory seems to be a red herring: Even without non-Ascii characters in the path to the home directory a sandboxed WkWebView just does nothing, while the non-sandboxed version works as expected. Gerriet. P.S. macOS 12.6 On 16 Oct 2017, at 19:23, Gerriet M. Denkmann <g@...> wrote: |
|
Gerriet M. Denkmann
On 16 Oct 2017, at 18:58, Sandor Szatmari <admin.szatmari.net@...> wrote: Do you have a catch all Objc exception breakpoint set?Yes I have, and: No there are no exceptions. I can imaging if the path to the volume is getting mangled and everything ‘seems’ ok that some call is failing and causing your delegate reference to fail. |
|
Sandor Szatmari
One thing that can cause delegate methods to never be called is if there’s been some sort of exception thrown, one that doesn’t crash the app but causes SDK internals to get all mucked up. Do you have a catch all Objc exception breakpoint set? I can imaging if the path to the volume is getting mangled and everything ‘seems’ ok that some call is failing and causing your delegate reference to fail.
toggle quoted message
Show quoted text
Sandor On Oct 16, 2017, at 07:46, Gerriet M. Denkmann <g@...> wrote: |
|
Sandor Szatmari
One thing that can cause delegate methods to never be called is if there’s been some sort of exception thrown, one that doesn’t crash the app but causes SDK internals to get all mucked up. Do you have a catch all Objc exception breakpoint set? I can imaging if the path to the volume is getting mangled and everything ‘seems’ ok that some call is failing and causing your delegate reference to fail.
toggle quoted message
Show quoted text
Sandor On Oct 16, 2017, at 07:46, Gerriet M. Denkmann <g@...> wrote: |
|
Gerriet M. Denkmann
macOS 12.6
When I start my sandboxed app, I get lots of messages like: “could not create “/Volumes/à¹à¸¡à¹à¸/Users/gerriet/Library/Containers/….”." Of course there is no disk-partition called “à¹à¸¡à¹à¸”. And when I check “/Volumes/เม่น/Users/gerriet/Library/Containers/….” all complained about folders have been created. So far so confusing. But when I do [ wkWebView loadHTMLString: … ] I see again: “could not create “/Volumes/à¹à¸¡à¹à¸/Users/gerriet/Library/Containers/de.mdenkmann.TestViewsMac/Data/Library/Caches/WebKit/NetworkCache”" and then nothing happens - no delegate method is ever called and the view remains blank. Any idea what I am doing wrong? Gerriet. P.S. works fine without sandboxing. And WebView works with or without sandboxing. |
|