1

I'm trying to tell if a user has specific system preferences set. I.e. the app needs to know if they've given Full Disk Access, if they've selected our app under Accessibility, etc. like in the picture below.

I know we can do something like

defaults read com.apple.AppleMultitouchTrackpad

but I'm having trouble finding this out for Full Disk Access, Files and Folders, and Accessibility under Security & Privacy.

Is there a list of the com.apple.XXX somewhere?

I'm basically trying to do something like

defaults read com.apple.security.Privacy_Accessibility

I'm able to open the system preferences pane with electron like

shell.openExternal('x-apple.systempreferences:com.apple.preference.security.Privacy_Accessibility')

So I thought there might be a way similar to this for reading the settings.

enter image description here

Cœur
  • 37,241
  • 25
  • 195
  • 267
Alex Cory
  • 10,635
  • 10
  • 52
  • 62

1 Answers1

2

To determine if accessibility access is enabled, you can use AXIsProcessTrusted and it's counterpart, AXIsProcessTrustedWithOptions. Both are part of ApplicationServices. From the documentation:

Returns TRUE if the current process is a trusted accessibility client, FALSE if it is not.

It doesn't seem possible to detect if FDA is enabled or not; there is no API for that. Some developers try to test access by attempting to read a known protected file and seeing if that works or not; but this approach is fragile and Apple does recommend against it. More discussion here.

TheNextman
  • 12,428
  • 2
  • 36
  • 75
  • 1
    Note that these privacy permissions are security policies, not ordinary preferences, so you can't check or set them with the usual `defaults` etc commands. – Gordon Davisson Dec 23 '19 at 22:59
  • How about checking the `Files and Folders`? – Alex Cory Dec 24 '19 at 00:09
  • @GordonDavisson how would you access them via CLI then? – Alex Cory Dec 24 '19 at 01:37
  • @AlexCory I don't think there's a way to. The whole system is rather opaque; see the [dev forum discussion TheNextman linked](https://forums.developer.apple.com/thread/114452). – Gordon Davisson Dec 24 '19 at 02:00
  • 1
    @AlexCory the whole permissions system is very fragmented, and like Gordon said, opaque. Some of the privacy settings have an API you can check but most don't. Worth reading/watching the WWDC 2019 session [Advances in macOS Security](https://developer.apple.com/videos/play/wwdc2019/701/) and you can read about `tcc`/`tccutil` although you'll find it has limited use for the consumer these days. – TheNextman Dec 24 '19 at 03:45
  • Thank you guys so much. I also found [mac-accessibility-features-check](https://github.com/4ndv/node-mac-accessibility-features-check) which I haven't tested yet, but it might just work (for at least one of my problems) – Alex Cory Dec 24 '19 at 04:06