Mac OSX 10.9.2,launchd错误:" launchctl:文件中的可疑所有权(跳过)"

时间:2014-05-08 14:28:50

标签: macos cron osx-mavericks launchd

我在三个不同的位置运行launchctl: Dubious ownership on file (skipping): ~.plist nothing found to load命令得到了同样的错误launchctl load,如下所示,并且它们都没有工作:

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

以下是我的updates.novel.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>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>

2 个答案:

答案 0 :(得分:4)

launchd服务需要由拥有plist文件的用户启动。如果所有者不是root用户,则不得使用sudo启动该服务。

此外,文件的权限必须拒绝对所有者以外的所有用户的写访问权。

最后,文件必须是常规文件(即不是管道或套接字或其他任何东西)。

答案 1 :(得分:1)

man launchctl我们可以阅读:

  

请注意,每用户配置文件(LaunchAgents)必须由加载它们的用户拥有。所有系统范围的守护进程(LaunchDaemons)必须由root拥有。配置文件不能是组或世界可写的。出于安全原因,这些限制已经到位。

这是launchctl.c检查:

的方式
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;

}

换句话说,请更正 .plist 文件的所有权,权限或路径,或强制加载(-F)。