[英]Mac OSX 10.9.2, launchd error: “launchctl: Dubious ownership on file (skipping)”
我遇到了相同的错误launchctl: Dubious ownership on file (skipping): ~.plist nothing found to load
launchctl load
在以下三个不同的位置运行launchctl load
命令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>
启动的服务需要由拥有plist文件的用户启动。 如果所有者不是root,则不得使用sudo启动服务。
此外,文件的权限必须拒绝所有者以外的所有用户的写访问权限。
最后,该文件必须是常规文件(即不是管道,套接字或其他任何文件)。
在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
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.