Find the answer to your Linux question:
Results 1 to 4 of 4
Hi, Executables with 'set user-id' bit set should be run with effective user id matching that of the file owner, instead of being set to the real user id of ...
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    4

    Set user id does not work for a program

    Hi,

    Executables with 'set user-id' bit set should be run with effective user id matching that of the file owner, instead of being set to the real user id of the user running the file. However, this does not happen on my system. Here is a program I used to test this:

    #include <iostream>
    using namespace std;
    #include <unistd.h>

    int main()
    {
    cout <<"Real: " <<getuid() <<" Effective: " <<geteuid() <<endl;
    return 0;
    }


    > g++ -o test test.cpp
    > chmod u+s test
    > ls -ln test
    -rwsrwxr-x 1 101 50 11151 2007-06-01 14:48 test*
    > id -ru
    101
    > ./test
    Real: 101 Effective: 101

    When I su to a different user, I get the following:

    > id -ru
    790
    > ./test
    Real: 790 Effective: 790

    This is wrong, since the effective user id should be 101, the owner of the file. I get the correct behavior on one linux system, but on another the above happens. Does anyone know what are the possible causes of this might be? Is set user-id bits disabled somehow on my system or is it something else?

    Thanks in advance.

  2. #2
    Just Joined!
    Join Date
    Feb 2007
    Posts
    76
    I'm not sure if this will help your problem but try installing perl-suid and then run the script that you're trying to run again.

  3. #3
    Just Joined!
    Join Date
    Jun 2007
    Posts
    4
    Quote Originally Posted by bigb89 View Post
    I'm not sure if this will help your problem but try installing perl-suid and then run the script that you're trying to run again.
    I'm not sure if this will help, since this has nothing to do with perl but with general system-wide properties. Also, I tested this on binary executables with above source, as well as on scripts, with the same incorrect results. Any other ideas?

  4. #4
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    It is quite possible that the systems are different. There is a mount option called 'nosuid' that prevents suid from taking effect. Make sure that you are not mounting your filesystem with the nosuid option (or an option that includes nosuid). You can find a listing of all mount options in the mount man page, under the '-o' segment.
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

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