本文介绍了带有NSTask的沙箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我启用了沙箱功能,并在NSTask中使用 / sbin / ping

I have sandboxing enabled and use /sbin/ping with NSTask:

[task setLaunchPath:@"/sbin/ping"];
[task setArguments:[NSArray arrayWithObjects:@"-c10", iPAddress, nil]];

一切正常,我得到了预期的输出。

Everything works great and I get the expected output.

我也想在NSTask中使用 / usr / sbin / traceroute

I also want to use /usr/sbin/traceroute with NSTask:

[task setLaunchPath:@"/usr/sbin/traceroute"];
[task setArguments:[NSArray arrayWithObject:iPAddress]];

但是任务以以下消息终止: NSTask:任务为路径 / usr / sbin / traceroute创建失败:22,参数无效。终止临时进程。 *
同时,沙箱日志:拒绝禁止执行-执行提示

But the task terminates with the message: NSTask: Task create for path '/usr/sbin/traceroute' failed: 22, "Invalid argument". Terminating temporary process.*At the same time the sandbox logs: deny forbidden-exec-sugid

为什么它可以与 ping 一起使用,但不能与 traceroute 一起使用吗?以及如何与 traceroute 配合使用?

Why does it work with ping, but not with traceroute ? And how do I make it work with traceroute ?

Thx!

推荐答案

Q1:ping与traceroute-前者是非特权程序,后者是特权并以root身份运行。您的错误表明沙盒不允许以root用户运行,这不足为奇。

Q1: ping vs. traceroute - the former is a non-priviledged program, the latter is priviledged and runs as root. Your error indicates running as root is not allowed by the sandbox, unsurprising.

第二季度:向Apple提交错误报告,详细说明了为什么需要traceroute功能并要求使用沙盒支持的方式。鉴于您实际上正在使用沙箱,因此您可能是注册的Apple开发人员,因此也请在开发人员论坛上提出它(列出您的错误号)。

Q2: file a bug report with Apple detailing why you need the traceroute functionality and ask for a sandbox supported way of doing it. Given you're actually using the sandbox you're probably a registered Apple developer, so raise it on the dev forums as well (list your bug number).

这篇关于带有NSTask的沙箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-15 17:13