Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Running programs under root with suid bit


    i've got a minimal test case with a C program with the following code

    #include <stdio.h>
    int main(){
    printf("uid = %d", getuid());
    printf("euid = %d", geteuid());
    After compiling the program and running it i get my own user id (1000), so thats fine.

    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.


    I'm running debian lenny, executing the exact same commands on the ping executable does give me the correct results...

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    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!

  3. #3

    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


  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts