Mac OS X 应用程序沙盒问题

发布于 2025-01-05 21:26:12 字数 229 浏览 3 评论 0原文

我正在编写一个命令行工具。我想在 /Users/user_name/Library 目录中创建一个目录。当我以 root 身份从终端运行该程序时,一切正常,但问题是当我想使用该工具作为 cups 的后端时(当我打印某些内容时,该程序也被称为 root )。程序被调用,但在system.log文件中我发现错误:sandboxd: Deny file-write-*。我是一名新的 Mac OS X 程序员,我不知道如何修复它。有人可以帮助我吗?

I am writing a command line tool. There I'd like to create a directory in the /Users/user_name/Library directory. When I run that program from Terminal as a root, then everything is ok, but the problem is when I want to use that tool as a backend for cups (that program is called, also as root, when I print something). The program is called, but in the system.log file I found the error: sandboxd: deny file-write-*. I'm a new Mac OS X programmer and I'm not sure how to fix it. Anybody can help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满意归宿 2025-01-12 21:26:12

由于 Snow Leopard cups 在沙箱中运行,因此可以防止其行为不当 - 例如访问用户的家。根据您的 OS X 版本,您可以使用另一个目录,而不是用户的主目录。在 Lion 上,它的限制甚至比这还要严格。沙箱规则内置于 cups 二进制文件中(与 sb 脚本相反),因此您唯一的运气可能是将 cups 替换为专门允许访问沙箱中所需内容的版本(如果您真的想去那里,规则由 cups/scheduler/process.c 中的 cupsdCreateProfile 定义。 AFAICT 您在应用程序中无能为力,因为沙箱旨在阻止您尝试执行的操作。

另一种选择是不以 root 身份运行 cups,因为仅当 cups 以 root 身份运行时才使用沙箱。

Since Snow Leopard cups is running in a sandbox that prevents it from misbehaving - like accessing user's home. Depending on your OS X version you can get away by using another directory, not user's home. On Lion it is even more restrictive than that. The sandboxing rules are built-in to the cups binary (as opposed to sb scripts), so your only luck may be replacing cups with a version that specifically allows access to what you need in the sandbox (if you really want to go there, the rules are defined by cupsdCreateProfile in cups/scheduler/process.c). AFAICT there is nothing you can do in your application, because sandboxing is designed to prevent exactly what you are trying to do.

Another alternative is to not run cups as root, because sandboxing is only used when cups is run as root.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文