0
我目前正在使用LaunchDaemons,並且遇到問題,launchd顯然使用了錯誤的用戶。launchd集合錯誤的用戶
這裏是我的LaunchDaemon的plist中(文件名是org.test.user.plist):
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.test.user</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/Users/Shared/test_user.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>_postgres</string>
<key>Umask</key>
<integer>000</integer>
<key>StandardOutPath</key>
<string>/Users/Shared/test_user.log</string>
<key>StandardErrorPath</key>
<string>/Users/Shared/test_user.log</string>
</dict>
</plist>
這LaunchDaemon只是執行腳本 'test_user.sh'。這是腳本的內容:
#!/bin/bash
postbat=/Users/Shared/BatScope4/pgdc/postbat_v1_0
echo "$(date '+%Y-%m-%d %H:%M:%S'):"
echo "user: $USER"
echo "id: $(id)"
echo "umask: $(umask)"
echo "$postbat:"
ls -Al "$postbat"
exit 0
與
sudo launchctl load -F org.test.user.plist
日誌文件test_user.log從慶典加載LaunchDaemon後包含以下內容:
2015-03-13 11:19:32:
user: _postgres
id: uid=216(_batscope) gid=216(_postgres) groups=216(_postgres),12(everyone),61(localaccounts),402(com.apple.sharepoint.group.1),408(com.apple.sharepoint.group.7),409(com.apple.sharepoint.group.8),403(com.apple.sharepoint.group.2),100(_lpoperator),401(com.apple.sharepoint.group.4),405(com.apple.sharepoint.group.6),404(com.apple.sharepoint.group.3),406(com.apple.sharepoint.group.5)
umask: 0000
/Users/Shared/BatScope4/pgdc/postbat_v1_0:
ls: postbat_v1_0: Permission denied
你需要什麼要知道的是,一旦用戶(和組)_postgres存在與UID = 216。但是,我刪除了它,並建立它具有以下屬性的新用戶_postgres:
PrimaryGroupID: 223
RecordName: _postgres
RecordType: dsRecTypeStandard:Users
UniqueID: 223
UserShell: /bin/bash
有誰知道,爲什麼launchd會一直使用舊的用戶_postgres,我怎麼能強迫它不?