Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the underlying user

Status
Not open for further replies.

lokachari

Programmer
Mar 18, 2002
5
0
0
US
Hi,

We have a group of users. These users after they login into the
unix system with their login id, they will then login to a common
account by doing $su - <commonAcct>.
After this they will run a shell script.
Is there any way that we can capture in this program who the underlying user invoked this program.

Example:
Say user ABC logged into the unix system. Now he will do su
$ su - <commonAcct>
password:
$ sh <executeProgram.sh>
This program <executeProgram.sh> should capture the user ABC.

We are using HPUX11.0

Please let me know how I can do this.

Thanks in Advance
Chari
 
Yeah, you don't create generic accounts that everyone uses. Otherwise, what is the point of having individual accounts and user groups?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Try using sudo. It can create a "sudolog" of who invoked sudo to run a command and when.

- Funky D
 
Yeah, you don't create generic accounts that everyone uses. Otherwise, what is the point of having individual accounts and user groups?

Its probably not that simple. For instance, Oracle requires you to have an account specific to it, and some things wont work unless theyre run as the user defined to it. iIn /var/adm/sulog, it holds all attempts to run the su command. man sulog.

___________________________________
[morse]--... ...--[/morse], Eric.
 
We create a generic account because the people keep changing for this particular access. So it is difficult to take out the access from that person when he is leaving and give access to new persons etc. Rather you can add and remove people from that common account.

Also having a common account is easy to control.

Thanks
Chari
 
Not sure about HPUX, but if you threw a "whoami" into the script, would this capture what you need?
 
have you s4r5 ptree ?

ptree pid-of-executeProgram.sh (this is $$)
gives you all father proc-id, now using
ps you sure are able to get the info.

 
Seems like HPUX does not support ptree command. When I type man ptree... it says no entry.
 
or mk by hand
following the ppid of pid in ps output
and the pppid of ppid
...until you find the login shell of pid
 
To get real user name try:[tt] id -urn[/tt]
 
For instance, Oracle requires you to have an account specific to it, and some things wont work unless theyre run as the user defined to it.

This is incorrect.

The only thing that Oracle requires is that only users belonging to a given Unix group (by default "dba") can obtain "SYSDBA" privilage. And this is only a requirement if Operating System authentication is being used.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top