LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   setuid issue (https://www.linuxquestions.org/questions/linux-general-1/setuid-issue-761756/)

ramukaka 10-14-2009 02:33 AM

setuid issue
 
I am running openSuse Linux. I want to create a file in /etc/ directory from a normal user, so what I did is, created a C program from root, compile it and set setuid bit(using command chmod ug+s ./a.out) of the executable generated. Now when I run the program from a normal user, it says "touch: cannot touch `/etc/test': Permission denied"

Here is my program.

#include<stdio.h>

int main()
{
system("touch /etc/test");
return 0;
}

Why it is saying permission denied as I had already set the setuid bit?

rkski 10-14-2009 02:43 AM

Hi
It's because of the permissions set on /etc/

ramukaka 10-14-2009 02:48 AM

Quote:

Originally Posted by rkski (Post 3718554)
Hi
It's because of the permissions set on /etc/

but since I already set setuid bit of executable, then it is suppose to run as owner of it which is root in my case and root has permissions to anything.

scott@tom:~> ls -la ./a.out
-rwsr-sr-x 1 root root 9505 2009-10-14 13:03 ./a.out

Even I has also tried by giving the write permission to /etc directory but it still not working.


All times are GMT -5. The time now is 01:25 PM.