It looks like in OS X 10.11 El Capitan, dtruss
and dtrace
can no longer do what they're meant to do. This is the error I get when I try to run sudo dtruss curl ...
:
dtrace: failed to execute curl: dtrace cannot control executables signed with restricted entitlements
I've come across people noticing this problem but so far no solutions.
Is there a way to fix this or work around this?
I would post this as a comment but I'm not allowed.
Disabling SIP is not necessary. Just copy the binary to an alternate location and it works just fine:
For binaries that can still function normally after being copied, this is the best option as it captures the entire lifetime of the process and doesn't require disabling any protections.
For those who want to dtrace system shipped binary after
csrutil disable
,copy
it to a directory that is not "restricted", for example,/tmp
See @J.J's comment: https://apple.stackexchange.com/questions/208762/now-that-el-capitan-is-rootless-is-there-any-way-to-get-dtrace-working/224731#224731
Looks like completely disabling SIP still blocks dtruss for restricted processes:
As Andrew notices it's because of System Integrity Protection, also known as "rootless".
You can disable it completely or partially (enable just dtrace with some limitations).
Instructions source: http://internals.exposed/blog/dtrace-vs-sip.html
Once you
csrutil enable --without dtrace
, there is an alternative to copying the binary: run the binary in one Terminal window and trace the Terminal process itself in another Terminal window.In the first terminal window, find its PID:
In the second terminal window, begin the trace:
Back, in the first terminal window, run the process you want to trace:
At this point, you should see the trace in the second window. Ignore the entries for the PID you are tracing (e.g., 1154), and the rest are for the process (and its descendants) you are interested in.
See my answer on related question "How can get dtrace to run the traced command with non-root priviledges?" [sic].
DTrace can snoop processes that are already running. So, start a background process which waits 1sec for DTrace to start up (sorry for race condition), and snoop the PID of that process.
Full explanation in linked answer.