5

I'm getting the same error launchctl: Dubious ownership on file (skipping): ~.plist nothing found to load from running a launchctl load command in three different locations as follows, and none of them is working:

sudo launchctl load /Library/LaunchDaemons/updates.novel.plist
sudo launchctl load /Library/LaunchAgents/updates.novel.plist
sudo launchctl load /Users/username/Library/LaunchAgents/updates.novel.plist

Below is my updates.novel.plist file, could you please take a look and let me know what is the problem? thanks

<?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>GroupName</key>
   <string>admin</string>
   <key>UserName</key>
   <string>Username</string>
   <key>Debug</key>
   <true/>
   <key>Label</key>
   <string>updates.novel</string>
   <key>ProgramArguments</key>
   <array>
      <string>/Applications/AMPPS/php-5.3/bin/php</string>
      <string>/Applications/AMPPS/www/files/allnovels/novel.php</string>
      <string>--daemon</string>
   </array>
   <key>StandardErrorPath</key>
   <string>/var/log/files/error.1.log</string>
   <key>StandardOutPath</key>
   <string>/var/log/files/error.2.log</string>
   <key>RunAtLoad</key>
   <true/>
   <key>AbandonProcessGroup</key>
   <true/>
   <key>StartCalendarInterval</key>
      <dict>
      <key>Hour</key>
      <integer>14</integer>
      <key>Minute</key>
      <integer>0</integer>
      </dict>
</dict>
</plist>
Sami
  • 1,473
  • 1
  • 17
  • 37
  • 2
    See http://apple.stackexchange.com/questions/3250/why-am-i-getting-a-dubious-ownership-of-file-error-when-launch-agent-runs-my, the top result when googling "launchd dubious ownership". – zneak May 08 '14 at 14:33
  • 1
    @zneak, I alreaday tried to `sudo chmod 644 `, but it didn't worked. – Sami May 08 '14 at 15:00
  • 1
    you get a dubious ownership message when you try to launch a service with a different user than the one to whom the file belongs. If you use `sudo`, it needs to be owned by `root`, but you don't need to use `sudo`. – zneak May 08 '14 at 15:08
  • @zneak, thanks a lot, you are right. I changed the UserName to `root` and run the `launchctl load /Library/LaunchAgents/updates.novel.plist`, and finally worked, cheers, – Sami May 08 '14 at 15:18

2 Answers2

4

launchd services need to be started by the user who owns the plist file. If the owner is not root, then the service must not be launched with sudo.

Also, the permissions on the file must deny write access to all users except the owner.

Finally, the file must be a regular file (ie not a pipe or a socket or anything else).

zneak
  • 134,922
  • 42
  • 253
  • 328
1

In man launchctl we can read:

Note that per-user configuration files (LaunchAgents) must be owned by the user loading them. All sytem-wide daemons (LaunchDaemons) must be owned by root. Configuration files must not be group- or world-writable. These restrictions are in place for security reasons.

This is how launchctl.c checks that:

bool path_goodness_check(const char *path, bool forceload) {

    if (forceload) {
        return true;
    }

    if (sb.st_mode & (S_IWOTH|S_IWGRP)) {
        fprintf(stderr, "%s: Dubious permissions on file (skipping): %s\n", getprogname(), path);
        return false;
    }

    if (sb.st_uid != 0 && sb.st_uid != getuid()) {
        fprintf(stderr, "%s: Dubious ownership on file (skipping): %s\n", getprogname(), path);
        return false;
    }

    if (!(S_ISREG(sb.st_mode) || S_ISDIR(sb.st_mode))) {
        fprintf(stderr, "%s: Dubious path. Not a regular file or directory (skipping): %s\n", getprogname(), path);
        return false;
    }

    if ((!S_ISDIR(sb.st_mode)) && (fnmatch("*.plist", path, FNM_CASEFOLD) == FNM_NOMATCH)) {
        fprintf(stderr, "%s: Dubious file. Not of type .plist (skipping): %s\n", getprogname(), path);
        return false;
    }

    return true;

}

So in other words, correct the ownership, permissions or path of your .plist file or force the loading (-F).

kenorb
  • 155,785
  • 88
  • 678
  • 743
  • *Thank you*! I was running into the "Not of type .plist" on some old HP TouchPad drivers when trying to start the `novacom` daemon. The `launchctl` script didn't have .plist appended, and thus it wouldn't start. – phatskat Jul 15 '15 at 19:35