Link to home
Start Free TrialLog in
Avatar of farzanj
farzanjFlag for Canada

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?
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of farzanj

ASKER

I ran it on Red Hat Linux (RHEL5.5).
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?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of farzanj

ASKER

Thank you so much for your clarification and your time.  Appreciated.