Results 1 to 3 of 3
Hello,
i've got a minimal test case with a C program with the following code
Code:
#include <stdio.h>
int main(){
printf("uid = %d", getuid());
printf("euid = %d", geteuid());
}
After ...
- 06-08-2010 #1Just Joined!
- Join Date
- Dec 2009
- Posts
- 7
Running programs under root with suid bit
Hello,
i've got a minimal test case with a C program with the following code
After compiling the program and running it i get my own user id (1000), so thats fine.Code:#include <stdio.h> int main(){ printf("uid = %d", getuid()); printf("euid = %d", geteuid()); }
Then i want to run it under root.
I do chown root.root <program name> and chmod 4771 <program name>
after running it again it still shows me 1000 as it's uid.
Trying stuff like loading modules also does not work, so it really does not have root.
Am i missing something here?
Any help would be greatly appreciated.
Ps.
I'm running debian lenny, executing the exact same commands on the ping executable does give me the correct results...
- 06-08-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Well, you have remove read permission from "others" (including yourself) which is one thing, and you haven't properly set the setuid bit(s).
First, set the proper permissions: chmod 755 cmdname
Then, set the setuid bit(s): chmod +s cmdname
Try that and see what happens.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 06-15-2010 #3Just Joined!
- Join Date
- Dec 2009
- Posts
- 7
Hello,
Thank you for your reply,
Sorry i have not been able to reply earlier, i've found the solution the partition was mounted with the nosuid flag, which makes using the suid bit kind of hard
Richard


Reply With Quote