macos - 在沙盒 mac 应用程序中执行 launchctl

标签 macos sandbox launchd

我需要从我的沙盒 OSX 应用程序中执行 launchctl load/unload 命令。该应用程序对启动代理的 plist 文件所在的文件夹具有读写权限(使用应用程序用户之前授予的安全范围书签)。

但是该应用会出现以下错误:

-
5/22/13 9:15:56.420 AM sandboxd[28463]: ([28473]) launchctl(28473) deny file-read-data /private/var/db/launchd.db/com.apple.launchd.peruser.501/overrides.plist
-

明确地说,我不想将我自己的应用程序添加到自动启动的启动项中,我还发现了这个 http://www.mail-archive.com/cocoa-dev@lists.apple.com/msg80413.html就类似话题进行的对话,目前还没有任何结果。

最佳答案

文件 /private/var/db/launchd.db/com.apple.launchd.peruser.501/overrides.plist 只能由管理员用户 (root) 读取或写入。因此,要使 launchctl load\unload 正常工作,您必须是 root 用户,或使用 sudo 在命令之前提升权限。但是,在沙盒中,您不能这样做。

根据您的需要,您可以使用 Helper 应用程序。看看Adding Login Items Using the Service Management Framework .

关于macos - 在沙盒 mac 应用程序中执行 launchctl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16685810/

相关文章:

macos - 2019 年 macOS 上的 SASL 状况如何?

java - JRuby 中的安全级别

java - Groovy Shell 沙箱最佳实践

macos - 在 bash 脚本中重试命令行直到成功,然后继续脚本

macos - 用于在启动时在 Mac 上自动启动 tomcat 的 plist

macos - 启动助手的 plist 文件中 SMPrivilegedExecutables 字符串的语法是什么?

linux - 我如何让 cron 作业每 30 分钟运行一次?

objective-c - 从服务启动时出现 OSX 代码签名无效异常

html - Google 跟踪代码管理器集成安全性 - noscript iframe 沙盒

macos - 未找到 CoreImage.framework