ijw*_*ijw 2 linux debugging privileges elevated-privileges
为了防止特权数据的泄漏,Linux上的setcap可执行文件不会转储核心:
ijw@build$ cat > test.c
main() { abort(); }
ijw@build$ gcc test.c
test.c: In function ‘main’:
test.c:1: warning: incompatible implicit declaration of built-in function ‘abort’
ijw@build$ ./a.out
Aborted (core dumped)
ijw@build$ sudo setcap "cap_net_admin=+ep" a.out
ijw@build$ ./a.out
Aborted
Run Code Online (Sandbox Code Playgroud)
有没有办法在调试时启用它并且实际上想要查看核心文件?
经过更多的研究,我有两个答案.
您可以完整地更改系统行为.这不仅仅适用于一个用户开发机器,但它可以解决问题:
echo 1 > /proc/sys/fs/suid_dumpable
Run Code Online (Sandbox Code Playgroud)
经过测试,有效.
您可以通过调用其中的prctl()来更改特定程序的行为:
prctl(PR_SET_DUMPABLE, 1);
Run Code Online (Sandbox Code Playgroud)
通过这种方式,特权程序自己确定它应该是可转储的,并且整个系统不受影响.
我没试过这个.