4

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
1
  • 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. Commented Nov 18, 2022 at 0:28

1 Answer 1

2

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.

1
  • Could someone edit this answer to clarify what exactly full access is given to? The .plist file in your LaunchDaemons directory, launchd, launchctl or something else?
    – Orestes
    Commented Jun 21 at 21:57

You must log in to answer this question.

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