2

One of the latest OS upgrades caused a script loaded by launchctl to fail for permissions.

my script does this to mirror a mounted path into my disk:

rsync -av --delete <mounted-path> <local-path>

I have no problem in running it manually, but running from the daemon I'm getting:

building file list ... rsync: opendir "<mounted-path>." failed: Operation not permitted (1)

I'm quite sure that I need to provide permission to the script, but couldn't find a way to grant the permission from System Prefs -> Security & Privacy -> Privacy -> Files and Folders. The [+/-] there is grayed off...

Any idea please?

EDIT: more data:

My plist: (com.mycompany.update-folder-from-nfs.plist)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.mycompany.update-folder-from-nfs</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/myname/Prog/something/uz-cpu/update_from_nfs_using_rsync.sh</string>
    </array>
    <key>StartInterval</key>
    <integer>45</integer>
</dict>
</plist>

Loading the plist:

launchctl unload ~/Library/LaunchAgents/com.mycompany.update-folder-from-nfs.plist || echo "ok"
cp com.mycompany.update-folder-from-nfs.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.mycompany.update-folder-from-nfs.plist
5
  • When you run it, do you run it as you or as root? Are the paths absolute or relative? LaunchAgents and Launch Daemons don’t need permissions they run as either a user you specify or as root which already have permissions. How are they being executed?
    – Allan
    Jun 22, 2020 at 17:11
  • Already checked that by writing log to file. The user is myself.
    – ishahak
    Jun 22, 2020 at 17:57
  • It might be best to post the plist and show how you’re loading it. We can then get a better picture
    – Allan
    Jun 23, 2020 at 2:31
  • added the plist as requested. thanks!
    – ishahak
    Jun 23, 2020 at 6:57
  • I think the problem is that your script will need "full disk access" permissions and as far as I can see there is now way to grant that to a script... It has to be wrapped up as an application. Nov 18, 2022 at 0:28

1 Answer 1

1

I encountered this same problem after upgrading to macOS Ventura. In my case, I had an existing LaunchDaemon that would run a scan over certain external disks. After upgrading, that LaunchDaemon started getting "Operation not permitted" errors.

In my case, it ended up being that Full Disk Access for the daemon got disabled by the upgrade. I just needed to go to System Settings -> Privacy and Security -> Full Disk Access, and re-enable the setting for my LaunchDaemon which I had previously added to Full Disk Access under the previous version of macOS.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .