Page 1 of 2
Create Folder with Sandboxed Mac App doesn't work
Posted: Fri Dec 18, 2020 4:24 pm
by booee
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!
Re: Create Folder with Sandboxed Mac App doesn't work
Posted: Fri Dec 18, 2020 6:38 pm
by FourthWorld
What do "the result" and "sysError()" show immediately after attempting to create the folder?
Re: Create Folder with Sandboxed Mac App doesn't work
Posted: Fri Dec 18, 2020 6:43 pm
by Klaus
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"
Re: Create Folder with Sandboxed Mac App doesn't work
Posted: Fri Dec 18, 2020 8:50 pm
by booee
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.
Re: Create Folder with Sandboxed Mac App doesn't work
Posted: Fri Dec 18, 2020 9:10 pm
by Klaus
Hm, I always thought we would defintively have write permisson in the users documents folder in any case, but obviously not.
Any ideas, Richard?
Re: Create Folder with Sandboxed Mac App doesn't work
Posted: Fri Dec 18, 2020 9:55 pm
by FourthWorld
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.
Re: Create Folder with Sandboxed Mac App doesn't work
Posted: Fri Dec 18, 2020 10:46 pm
by booee
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.
Re: Create Folder with Sandboxed Mac App doesn't work
Posted: Fri Dec 18, 2020 11:52 pm
by booee
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?
Re: Create Folder with Sandboxed Mac App doesn't work
Posted: Sat Dec 19, 2020 1:46 pm
by paul@researchware.com
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.
Re: Create Folder with Sandboxed Mac App doesn't work
Posted: Sat Dec 19, 2020 4:40 pm
by booee
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.
Re: Create Folder with Sandboxed Mac App doesn't work
Posted: Sat Dec 19, 2020 6:01 pm
by booee
I do notice these errors in AppWrapper (not sure if it's part of the issue)
https://ibb.co/9ydzmYy
Re: Create Folder with Sandboxed Mac App doesn't work
Posted: Sat Dec 19, 2020 6:16 pm
by SparkOut
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.
Re: Create Folder with Sandboxed Mac App doesn't work
Posted: Sat Dec 19, 2020 7:39 pm
by booee
That also doesn't work. I errorCode 2 and errorCode 1 from that.
Again though, it works BEFORE the project gets Sandboxed.
Re: Create Folder with Sandboxed Mac App doesn't work
Posted: Sat Dec 19, 2020 7:55 pm
by booee
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?
Re: Create Folder with Sandboxed Mac App doesn't work
Posted: Sun Dec 20, 2020 5:13 pm
by booee
So now for some reason sysError is returning 34