farzanj
asked on
UID/GID on Executable: Effective vs. Real UID concept
I wrote a short C++ program that only receives an input value (basically cin >> a ;). I enabled UID on it. So ls -l shows:
-rwsr-xr-x 1 root root 6058 Sep 15 09:50 prog
Now I executed it as "test" user and checked the real vs. effective UID as under:
ps -eo cmd,ruser,euser,ruid,euid, pid | grep prog | grep -v grep
./prog test root 501 0 14251
Just as I expected, real userid is 501(test) and effective uid is 0(root).
So far so good.
Now I tried to do the same using a shell script. A bash script called script which should do the same thing but it doesn't. Why? Is there a way to see it working in a shell script.
-rwsr-xr-x 1 root root 5 Sep 15 09:29 script
ps -eo cmd,ruser,euser,ruid,euid, pid | grep 14328
bash test test 501 501 14328
Second, will the script work as root or as user test?
-rwsr-xr-x 1 root root 6058 Sep 15 09:50 prog
Now I executed it as "test" user and checked the real vs. effective UID as under:
ps -eo cmd,ruser,euser,ruid,euid,
./prog test root 501 0 14251
Just as I expected, real userid is 501(test) and effective uid is 0(root).
So far so good.
Now I tried to do the same using a shell script. A bash script called script which should do the same thing but it doesn't. Why? Is there a way to see it working in a shell script.
-rwsr-xr-x 1 root root 5 Sep 15 09:29 script
ps -eo cmd,ruser,euser,ruid,euid,
bash test test 501 501 14328
Second, will the script work as root or as user test?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much for your clarification and your time. Appreciated.
ASKER
Second, please clarify if effective uid/gid the one that is checked for determining the access/permissions. Does real uid/gid ever matter at all?