Any API info on permitting Full Disk Access without user intervention?

Hi Folks,

As some of us have discovered, 10.14 GM <> 10.14 Developer betas. The new “Full Disk Access” idiocy is having a negative affect on tools that need to do things that Apple have now deemed “suspicious”. Even the root user can’t access things like a user’s Mail folder.

I’m aware of the “Security and Privacy” -> “Full Disk Access” settings, but it seems that setting only supports bundled apps and not console helper apps.

Are any of you that live in the macOS API/SDK more deeply than me aware of APIs that allow us to sort this in our apps without user intervention?

That would bypass security. So no dice.

But the security is beyond stupid. I can get a references to a folder in the Mail folder. But counting items always gives me a fat 0.

[code]dim f as FolderItem = GetFolderItem("/Users/beatrixwillius/Library/Mail/V6/18EA0B79-2DA3-44E4-8D24-346258E3EE24", FolderItem.PathTypeShell)
if f = Nil then Return
dim i as Integer = f.Count

MsgBox str(i)[/code]

So how does my competitors handle this? Shell? AppleScript?

Does that still occur once your app has been granted full disk access?

Beatrix… was that folder (the UUID) just an example?
I have found 12 subfolders in my Main/V6 , 11 of them in the UUID format, and 1 “MailData”

but you are correct… .they all return Zero, even though I have visually confirmed they contain files

@Tim Parnell: yes, I built a version of the app and gave that full disk access.

@Dave S: yes, the folder is an example.

AppleScript in Script Editor:

tell application "Finder" set file_list to name of every file of entire contents of (choose folder with prompt "Please select directory.") end tell

Gives

[quote]error “„Finder“ hat einen Fehler erhalten: „every file of folder “81763DE9-295A-46D6-A41B-90C7FF0FD522” of folder “Archive.mbox” of folder “18EA0B79-2DA3-44E4-8D24-346258E3EE24” of folder “V6” of folder “Mail” of folder “Library” of folder “beatrixwillius” of folder “Users” of startup disk“ kann nicht gelesen werden.” number -1728 from every file of folder “81763DE9-295A-46D6-A41B-90C7FF0FD522” of folder “Archive.mbox” of folder “18EA0B79-2DA3-44E4-8D24-346258E3EE24” of folder “V6” of folder “Mail” of folder “Library” of folder “beatrixwillius” of folder “Users” of startup disk

Kann nicht gelesen werden = can’t be read[/quote]

Shellscript in Xojo:

[code]dim s as string = “ls /Users/beatrixwillius/Library/Mail/V6/18EA0B79-2DA3-44E4-8D24-346258E3EE24/Archive.mbox”
dim theShell as new Shell
theShell.Execute s
if theShell.ErrorCode <> 0 then Return

msgbox theShell.Result[/code]

Makes an IOException 1.

So, I’m not blind and didn’t miss some big SDK documentation location for this.

I know that I can enable it for a bundled app by setting the whitelist entry for the bundled parent app. My issue is that there is no way to do this for a console, non-bundled app.

I’ve filed a RADAR on this requesting support for non-bundled apps and was very polite and kept my iOS commentary at bay, but we know how Apple is about their security baby.

[quote=426554:@Beatrix Willius]@Tim Parnell: yes, I built a version of the app and gave that full disk access.

@Dave S: yes, the folder is an example.

AppleScript in Script Editor:

tell application "Finder" set file_list to name of every file of entire contents of (choose folder with prompt "Please select directory.") end tell

Gives

Shellscript in Xojo:

[code]dim s as string = “ls /Users/beatrixwillius/Library/Mail/V6/18EA0B79-2DA3-44E4-8D24-346258E3EE24/Archive.mbox”
dim theShell as new Shell
theShell.Execute s
if theShell.ErrorCode <> 0 then Return

msgbox theShell.Result[/code]

Makes an IOException 1.[/quote]

What does:

ls -al@ /Users/beatrixwillius/Library/Mail/V6/18EA0B79-2DA3-44E4-8D24-346258E3EE24

show?

Permission denied.

Unless you add Terminal.App to your whitelist.

IDK if this will help, but to get console apps to access files from a Sandboxed application, you have to use IPC and pass a non-secure Security-Scoped Bodgemark while the main application holds open a Secure Security-Scoped Bodgemark. Once the console application has accessed the file, the main app can then safely relinquish access on the Security-Scoped Bodgemark, and then the console app can still access the file.

Or you just move the file to a location the console application can access.

The ls in Terminal works fine:

[quote]ls -al@ /Users/beatrixwillius/Library/Mail/V6/18EA0B79-2DA3-44E4-8D24-346258E3EE24
total 96
drwxr-xr-x@ 10 beatrixwillius staff 320 1 Mr 01:59 .
com.apple.quarantine 19
drwxr-xr-x@ 13 beatrixwillius staff 416 23 Feb 06:03 …
com.apple.quarantine 19
-rw-r–r--@ 1 beatrixwillius staff 48191 1 Mr 01:59 .mboxCache.plist
com.apple.quarantine 19
drwxr-xr-x@ 4 beatrixwillius staff 128 22 Feb 18:46 Archive.mbox
com.apple.quarantine 19
com_apple_mail_mailboxDirectoryCompressed 1
drwxr-xr-x@ 4 beatrixwillius staff 128 26 Feb 16:31 Deleted Messages.mbox
com.apple.quarantine 19[/quote]

Does the app need to be signed when accessing Mail data? This is just my testing laptop here where I don’t do any signing. That would make debugging truly foobared.

Unfortunately not that easy. In order to be “whitelisted”, the helper tool must also be a bundle, not just within the bundle.

To see what I mean, try this on a 10.14 system:

sudo tar -cvvvf /dev/null ~/Library/Mail

Go to the Security and Privacy preferences panel and add /usr/bin/tar to the whitelist

Try the command again

Now, add Terminal.app to the whitelist

Try the command again

Codesigning did the trick. However, I had to remove the old version of my app from Security preferences and add the new version.

Can this work during debug at all? You have to restart the app after changing the security. Need to test.

Oh no. Now I have to do the awful 2-factor authentication stuff. Gag…

Do you mean a combination of codesiging the app and whitelisting it?

While I haven’t had to tackle this particular problem I can tell you that with the AppleScript permissions you have to re-allow the specific access in the security preferences whenever you update the app. The problem is that it doesn’t actually disable it, it appears that it is still granted permission but it won’t actually allow them until you go into that manually, uncheck and re-check the checkbox. It doesn’t do this all the time, but enough that I’ve had to tell users about it as a debugging tool. The new security stuff is horrible. Not that the idea is horrible, but the implementation is horrible and buggy and inconsistent and causing me all sorts of headaches too.

Yep. Whitelisting without codesigning didn’t work. I took the signed app from my main computer and copied it to the computer with Mojave.

I wasn’t up to do the 2factor today so I’m not sure what the behaviour in the debugger is.

Since whitelisting adds a plist entry to a bundled app, you would need to run paused, re-add the current debug build to the whitelist, and then launch.

For every debug run? No thanks. That would be this one here: NSAllowsArbitraryLoads .

What would happen if I added the plist entry myself? But then the app still needs to be codesigned. Which is way too slow for debugging.

I’m going to add back my slow AppleScript code so that I can do testing in debug mode.

I’m not sure why your code signing step takes so long. I use an IDE script as the last part of my build steps and it adds maybe 10 seconds to my largest project.

I believe that this entry is invalid for a non-codesigned app bundle … in other words, the app must be code signed in order for that entry to be added.

Surprisingly, I received a follow up from Apple on the lack of non-bundled binary support in the Full Disk Access whitelist.

Unsurprisingly, their answer was a now standard “That’s the way it’s supposed to work.” They even went so far as to recommend enabling FDA for Terminal.App - which is hilarious since that obviates the FDA protocol completely.

I’ve now used a development incident to ask for a way to solve this at my end - <cues Jeopardy “Final Jeopardy” theme…>