在OS X 10.11操作系统的ps上truss失败



我试图查看ps使用哪个系统调用来获取OS X 10.11 (El Capitan)上进程的命令行,并遇到以下错误:

# dtruss ps -p 43520 -o args
dtrace: failed to execute ps: dtrace cannot control executables signed with restricted entitlements

谷歌导致的建议,使ps的副本将允许我绕过这一点,但这对我不起作用。为什么我不能在任意二进制文件上运行dtruss,我有办法恢复旧的行为吗?

问题与代码签名有关。如果你做了一个副本,然后用你自己的身份(或者,假设,任何非苹果的身份)重新签名,那么dtrace就会附着在它上面。

$ mkdir ~/temp
$ cp /bin/ps ~/temp/
$ codesign -f -s `whoami` ~/temp/ps
$ sudo dtruss ~/temp/ps -p 43520 -o args

无法控制使用受限权限签名的可执行文件

安全完整性保护('rootless')现在阻止dtruss在这里操作。

您可以通过启动到恢复模式来禁用它,但是看起来dtrace已经被特别地阻塞了,无论无根状态如何,如果您搜索"dtrace cannot control",可以在源代码中看到。

您还可以从Pcreate中的注释中看到:

    /*
     * <rdar://problem/13969762>:
     * If the process is signed with restricted entitlements, the libdtrace_dyld
     * library will not be injected in the process. In this case we kill the
     * process and report an error.
     */

最新更新