【问题标题】:Error while executing .plist file Path had bad ownership/permissions执行 .plist 文件时出错路径的所有权/权限错误
【发布时间】:2015-03-19 18:12:38
【问题描述】:

terminal 中执行plist 文件时出错

错误:Path had bad ownership/permissions

1) 我使用xcode 6 创建了一个plist 文件并将plist 文件保存在路径library/launchdaemons/myfile.plist

myfile.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>myfile</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Desktop/myscript.sh</string>
    </array>
    <key>StartCalendarInterval</key>
    <array>
        <dict>
            <key>Hour</key>
            <integer>14</integer>
            <key>Minute</key>
            <integer>35</integer>
        </dict>
    </array>
</dict>
</plist>

2) 在终端中我使用sudo launchctl load 命令加载plist 文件

sudo launchctl load /library/launchdaemons/myfile.plist

3) 之后我收到此错误

/Library/LaunchDaemons/myfile.plist: Path had bad ownership/permissions

我哪里出错了?

【问题讨论】:

    标签: terminal plist


    【解决方案1】:

    尝试更改 .plist 文件的所有权:

    sudo chown root /Library/LaunchDaemons/myfile.plist
    sudo chgrp wheel /Library/LaunchDaemons/myfile.plist
    

    或者更简单地说,在一个命令中更改用户和组:

    sudo chown root:wheel /Library/LaunchDaemons/myfile.plist
    

    还值得注意的是,出于安全原因,这些根 LaunchDaemons 不能是全局可写的:

    sudo chmod o-w /Library/LaunchDaemons/*
    

    【讨论】:

    • 是的,这是正确的解决方案,但在 4 天之前我还是得到了解决方案,谢谢
    • @Vivek 你应该已经分享了你的解决方案。
    • @MatterGoal:回到这里的那 4 天里,我无法访问 Stackoverflow,我看到了发布的解决方案。
    【解决方案2】:

    plist 文件必须由 root 和 group wheel 作为 rw 所有者拥有。 所以root:wheel 600

    【讨论】:

    • 这对于解决问题至关重要
    【解决方案3】:

    除上述之外

    sudo chmod 600 /directoryToFile/filename.plist
    

    例如:

    sudo chmod 600 com.backup.plist
    

    sudo chmod 600 /Library/LaunchDaemons/myfile.plist
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-22
      • 2017-06-14
      • 2015-11-09
      相关资源
      最近更新 更多