I am working on a macOS app which is distributed outside of the App Store, but it is notarized.
The app contains macOS agent wsmon
. It is located at App.app/Contents/Resources/wsmon. It does not have GUI, but it is visible in the system bar.
The agent requires to record the content of the screen and communicate with Safari using automation.
The Info.plist
of App.app
contains:
<key>NSAppleEventsUsageDescription</key>
<string>...</string>
<key>NSAppleScriptEnabled</key>
<true/>
The App.app
and wsmon
have same entitlements:
$ codesign -d --entitlements :- App.app/Contents/Resources/wsmon
<dict>
<key>com.apple.security.automation.apple-events</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<false/>
</dict>
I run wsmon
by the command:
$ launchctl load /Library/LaunchAgents/com.domain.App.wsmon.plist
$ launchctl list | grep wsmon
3050 0 com.domain.App.wsmon
In a minute, would like to record computer's screen dialog opens.
I run System Preferences and check wsmon
to allow record screen. It is correct, but I expected to see App instead of wsmon, because wsmon is part of App.app.
When wsmon
communicate with Safari, wants access to control Safari dialog opens. I click OK and the agent successfully communicates with Safari.
Then I open the System Preferences, Automation pane. Unfortunately wsmon
is not there. I am not able to allow or disallow wsmon access Safari. If a user did not allow the access, he will not be able to change it. Only after I reset the decision by $ tccutil reset AppleEvents
, the dialog opens again and I can click allow or don't allow button.
I grad full access to Terminal, but TCC.db does not contain wsmon
for kTCCServiceListenEvent, only for screen recording:
$ sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" "select service, client from access where client like '%wsmon%'"
kTCCServiceScreenCapture|/Applications/App.app/Contents/Resources/wsmon
Please clarify:
- Why client column of TCC.db contain the path to
wsmon
binary and not CFBundleIdentifier ofApp.app
nor com.domain.App.wsmon?wsmon
belongs toApp.app
and is not distributed separately. - How to reset kTCCServiceScreenCapture for the agent using tccutil?
tccutil reset AppleEvents com.domain.App.wsmon
does not work. - Why Automation pane and TCC.db do not contain the agent
wsmon
to allow/disallow?