Create Folder with Sandboxed Mac App doesn't work

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

booee
Posts: 41
Joined: Fri Mar 27, 2015 9:48 pm

Create Folder with Sandboxed Mac App doesn't work

Post by booee » Fri Dec 18, 2020 4:24 pm

When I do the following in my Livecode application it works fine in Development:

Code: Select all

create folder specialFolderPath("documents") & "/Booee/"
However, when I Sandbox my application (using App Wrapper), it doesn't work and won't create that folder.

Can you NOT create folder too the "documents" area in a Sandboxed application?

Thanks for any help!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Create Folder with Sandboxed Mac App doesn't work

Post by FourthWorld » Fri Dec 18, 2020 6:38 pm

What do "the result" and "sysError()" show immediately after attempting to create the folder?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Create Folder with Sandboxed Mac App doesn't work

Post by Klaus » Fri Dec 18, 2020 6:43 pm

Just to be sure:
Please also try with PARENS!

Code: Select all

create folder (specialFolderPath("documents") & "/Booee/")
And/or without the trailing SLASH:

Code: Select all

create folder (specialFolderPath("documents") & "/Booee"

booee
Posts: 41
Joined: Fri Mar 27, 2015 9:48 pm

Re: Create Folder with Sandboxed Mac App doesn't work

Post by booee » Fri Dec 18, 2020 8:50 pm

So I tried the recommendations of Klaus:

With both the trailing slash and without I get an result of: "can't create that directory"
and the sysError() returns "17"

Update:
The sysError actually returns "2" first, and then "17" every time after I attempt again.
Last edited by booee on Fri Dec 18, 2020 9:48 pm, edited 1 time in total.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Create Folder with Sandboxed Mac App doesn't work

Post by Klaus » Fri Dec 18, 2020 9:10 pm

Hm, I always thought we would defintively have write permisson in the users documents folder in any case, but obviously not.

Any ideas, Richard?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Create Folder with Sandboxed Mac App doesn't work

Post by FourthWorld » Fri Dec 18, 2020 9:55 pm

17 is usually 'EEXIST' on Unix systems like maOS, i.e. "file already exists".

But if the file and its containing folder allow writes, I don't know why the previous existence should matter.

Can you create the folder manually? I'm not suggesting that as a solution, just for diagnostics.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

booee
Posts: 41
Joined: Fri Mar 27, 2015 9:48 pm

Re: Create Folder with Sandboxed Mac App doesn't work

Post by booee » Fri Dec 18, 2020 10:46 pm

Yeah, I can create it manually.
And in development (in Livecode), as well as a non-Sandboxed App, it creates the folder.

The issue arises only after I Sandbox the app (which I use AppWrapper to do).
But if the file and its containing folder allow writes, I don't know why the previous existence should matter.
I haven't even tried "writing" a file. I'm simply trying to create a folder, so I'm only using the line you provided.

booee
Posts: 41
Joined: Fri Mar 27, 2015 9:48 pm

Re: Create Folder with Sandboxed Mac App doesn't work

Post by booee » Fri Dec 18, 2020 11:52 pm

I think I found the issue, but I'm not sure how to resolve it exactly:
I added a line that said answer specialFolderPath("documents") & "/Booee/"
This was the output:
/Users/randyl/Library/Containers/com.booee.booee/Data/Documents/Booee
For some reason it's trying to write to the "documents" folder within all of that stuff for some reason.
Any ideas?

paul@researchware.com
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 135
Joined: Wed Aug 26, 2009 7:42 pm
Location: Randolph, MA USA
Contact:

Re: Create Folder with Sandboxed Mac App doesn't work

Post by paul@researchware.com » Sat Dec 19, 2020 1:46 pm

I have a similar problem creating folders in specialFolderPath("temporary") under Catalina or Big Sur. The error appears to happen only from an externally loaded stack. i.e. if my signed and notarized app tries to create a temporary folder, it works, but if I load a stack external (to my signed and notarized and stapled) standalone and it tries to create a temp folder, the error occurs. I have not had time to create a test stack to reproduce the error. I just instruct users to grant my app "Full Disk Access" under Security and Privacy and they seem fine doing that. We're not the only commercial app that has asked it's customer on those version of macOS to grant their app full disk access to address weirdness in Apple entitlements system. On the Apple forums, apple engineers have even stated that it can guess wrong about when to present a permissions dialog and block app when it should ask for permission.
Paul Dupuis
Researchware, Inc.

booee
Posts: 41
Joined: Fri Mar 27, 2015 9:48 pm

Re: Create Folder with Sandboxed Mac App doesn't work

Post by booee » Sat Dec 19, 2020 4:40 pm

I guess my confusion/problem is why specialFolderPath("documents") path changes from
/Users/randyl/Documents/Booee/ to /Users/randyl/Library/Containers/com.booee.booee/Data/Documents/Booee
after Sandboxing.

I'm not sure it's really a security issue, rather than something else is going on.

As a test, I did your recommendation of giving it full access and the issue still remains.

booee
Posts: 41
Joined: Fri Mar 27, 2015 9:48 pm

Re: Create Folder with Sandboxed Mac App doesn't work

Post by booee » Sat Dec 19, 2020 6:01 pm

I do notice these errors in AppWrapper (not sure if it's part of the issue)
https://ibb.co/9ydzmYy

SparkOut
Posts: 2839
Joined: Sun Sep 23, 2007 4:58 pm

Re: Create Folder with Sandboxed Mac App doesn't work

Post by SparkOut » Sat Dec 19, 2020 6:16 pm

I don't use a Mac so just a quick comment/question:

Purely as a test, what results if you hard code the "normal" documents path instead of that specialFolderPath that resolves to that long path into your sandboxed app? This should hopefully at least determine whether it is a permissions issue or a path issue.

It sounds like you might need to raise a bug ticket for this, so the team can update the specialFolderPath function to cater for new path structures in latest OS versions.

But like I said, I am not a Mac user so have no authoritative idea.

booee
Posts: 41
Joined: Fri Mar 27, 2015 9:48 pm

Re: Create Folder with Sandboxed Mac App doesn't work

Post by booee » Sat Dec 19, 2020 7:39 pm

That also doesn't work. I errorCode 2 and errorCode 1 from that.
Again though, it works BEFORE the project gets Sandboxed.

booee
Posts: 41
Joined: Fri Mar 27, 2015 9:48 pm

Re: Create Folder with Sandboxed Mac App doesn't work

Post by booee » Sat Dec 19, 2020 7:55 pm

I did notice this just now:
viewtopic.php?t=34055
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
</dict>
My info.plist does NOT contain these things. Any idea why?

booee
Posts: 41
Joined: Fri Mar 27, 2015 9:48 pm

Re: Create Folder with Sandboxed Mac App doesn't work

Post by booee » Sun Dec 20, 2020 5:13 pm

So now for some reason sysError is returning 34

Post Reply

Return to “Mac OS”