Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OSX 10.9.2, launchd error: "launchctl: Dubious ownership on file (skipping)"

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>
like image 431
Sami Avatar asked May 08 '14 14:05

Sami


2 Answers

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).

like image 88
zneak Avatar answered Nov 14 '22 03:11

zneak


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).

like image 23
kenorb Avatar answered Nov 14 '22 03:11

kenorb