我正在为在教学套件中运行的MacMini套件执行以下操作。
我有90%的代码都在工作,但是试图让我的plist工作和加载完全陷入困境。
它可以在我的计算机(也为10.13)上运行,并且可以正常加载,可以在同一台Mac上以管理员身份加载。 尝试以用户身份加载它不起作用。
运行以下Bash脚本:
#! /bin/bash
# Supercedes the above make user , this CANNOT be run as root , so run as the administrator user we added at creation.
sysadminctl -addUser student -fullName "Bamm Student" -password student -hint student
createhomedir -c /Users/student
# Import the parental controls plist
dscl . -mcximport /Users/student /tmp/parental_controls.plist
# Dock script needs to be copied to the correct location first
# Set the permissions on the dock script
chmod +x /usr/local/dock.sh
chown student:staff /usr/local/dock.sh
这部分全部正常工作,我得到一个用户,我得到了主目录,我将停靠脚本复制到了/usr/local
(并且当以用户身份从命令行运行时,它可以工作)
/Users/student/LaunchAgents/
这是行不通的(我已经尝试了很多方法)
# load the dock launchAgent (run as the student user)
launchctl load /Users/student/Libray/launchAgent/com.mitsuite.login.plist
给予/Users/temp/Library/LaunchAgents/com.mitsuite.login.plist: Operation not permitted
我也尝试过
launchctl bootstrap gui/502 /Users/student/Libray/launchAgent/com.mitsuite.login.plist
给予Could not find domain for
launchctl bootstrap user/502 /Users/student/Libray/launchAgent/com.mitsuite.login.plist
这些给我system.log
中的各种错误,主要是这样的:
Aug 10 15:12:59 MIT-1 com.apple.xpc.launchd[1] (com.apple.xpc.launchd.user.domain.501.100008.Aqua): Caller not allowed to perform action: launchctl.671, action = service bootstrap, code = 1: Operation not permitted, uid = 502, euid = 502, gid = 20, egid = 20, asid = 649
我尝试创建标准用户而不添加任何家长控制(通过管理面板,没有编写脚本的乐趣),并且遇到相同的问题。
我的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>local.job</string>
<key>Program</key>
<string>/usr/local/dock.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
作为测试,我在同一台计算机上创建了一个admin用户,并运行了该命令,所有操作都能很好地加载plist并在启动时运行。
如何让标准用户通过命令行安装plist?
关于另一个Stackoverflow问题,我已经将用户名添加到.plist文件中,然后将其放在/ Library / LaunchDaemons中,当root运行launchctl load /Library/LaunchDaemons/com.mitquite.login.plist时,所有这些都可以使用
但是,这似乎很不直观(除非其意图是因为标准用户无法安装应用程序?)
答案 0 :(得分:1)
我会尝试做两件事:
<string>
下<key>Label</key>
字段中的值更改为com.mitsuite.login
而不是local.job
或添加到.plist(至少前两行):
<key>UserName</key>
<string>/*name_of_user*/</string>
<key>GroupName</key>
<string>/*group_name*/</string>
<key>InitGroups</key>
<true/>