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 ...
- 06-01-2007 #1Just 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.
- 06-01-2007 #2Just 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.
- 06-01-2007 #3Just Joined!
- Join Date
- Jun 2007
- Posts
- 4
- 06-02-2007 #4
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


Reply With Quote
