Originally Posted by xeveri
I am new to linux and i choose slackware.
When learning set user id,i am confused about it.So i decide to try with a script.
For security reasons, SUID is disabled/ignored for shell scripts
. I believe this is configurable when you compile the kernel, so caveat lector for other distros.
If you were to compile the following C code
, and set the permissions of the resulting binary for SUID, things will work as one'd expect.
fp = fopen("/tmp/test.txt", "w");
root@faraday:~# gcc test.c -o /tmp/testsuid
root@faraday:~# chmod u+s -v /tmp/testsuid
mode of '/tmp/testsuid' changed from 0755 (rwxr-xr-x) to 4755 (rwsr-xr-x)