Applications started from launchd on macOS Catalina cannot access files
Hi, I'm developing a command line tool that periodically checks the contents of removable disks.This program is automatically executed using launchd in order to run at OS startup.
It worked fine until macOS 10.14, but an access error occurred in 10.15.
Error:
Sandbox: dirtest(4673) System Policy: deny(1) file-read-data /Volumes/USB HDD
If this program is executed directly from the terminal, no access error will occur.
Question:
Why can't a program started from launchd have file access to a removable disk?
Is there a better solution?
Supplementary information:
This program allows access to Removable Volumes in the Security & Privacy system settings.
However, the access right seems to be invalidated when started from launchd.
A simple program to reproduce this problem:
Here's the *.plist file:
And here's the startup script:
MacBook Pro 15", OS X 10.11