Running programms with S-Bit set - Linux

This is a discussion on Running programms with S-Bit set - Linux ; Hi, when running a program with the s-Bit set (chmod 4755) the program is run under the permissions of the user who is owner of the program. Example: if a program foo belongs to the user foouser1 and the user ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Running programms with S-Bit set

  1. Running programms with S-Bit set

    Hi,

    when running a program with the s-Bit set (chmod 4755) the program is
    run under the permissions of the user who is owner of the program.
    Example: if a program foo belongs to the user foouser1 and the user
    foouser2 executes foo, then foo runs as it was started from foouser1.

    Assuming that foo is a C-Programm: Is it possible to get the user who
    executes foo (i.e. foouser2) ? I know how to get the uid and the p_uid,
    but this won't help because these belongs to foouser1 or the
    init-process.

    Thanks

    Dierk


  2. Re: Running programms with S-Bit set

    dierkb wrote:
    > Hi,
    >
    > when running a program with the s-Bit set (chmod 4755) the program is
    > run under the permissions of the user who is owner of the program.
    > Example: if a program foo belongs to the user foouser1 and the user
    > foouser2 executes foo, then foo runs as it was started from foouser1.
    >
    > Assuming that foo is a C-Programm: Is it possible to get the user who
    > executes foo (i.e. foouser2) ? I know how to get the uid and the p_uid,
    > but this won't help because these belongs to foouser1 or the
    > init-process.


    man geteuid

    getuid returns the real user ID of the current process.

    geteuid returns the effective user ID of the current pro*
    cess.

    The real ID corresponds to the ID of the calling process.
    The effective ID corresponds to the set ID bit on the file
    being executed.

    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett


  3. Re: Running programms with S-Bit set

    On 2007-01-25, dierkb wrote:
    > Hi,
    >
    > when running a program with the s-Bit set (chmod 4755) the program is
    > run under the permissions of the user who is owner of the program.


    AKA setuid bit.

    > Example: if a program foo belongs to the user foouser1 and the user
    > foouser2 executes foo, then foo runs as it was started from foouser1.


    > Assuming that foo is a C-Programm: Is it possible to get the user who
    > executes foo (i.e. foouser2) ?


    Definately. I misremember how.

    > I know how to get the uid and the p_uid, but this won't help because
    > these belongs to foouser1 or the init-process.


    how about getuid



    --

    Bye.
    Jasen

+ Reply to Thread