Re: getting login name in 4GL
Posted in 1996
Kevin Franden wrote: > The best way (IMHO) to address this issue is to do somthing like: > > #include <pwd.h> > . > . > . > { > struct passwd *pw; > > pw=getpwuid(getuid()); /* fetch the passwd entry */ > > /* now, pw->pw_name contains what USER and/or LOGNAME should */ > } > > Pretty simple. Hope this helps. Like I posted before, this will return the user which matched the effective UID. This does not necessarily match USER or LOGNAME. LOGNAME should be a read only variable. THis is true for AIX(4.13) and HP-UX (9.04 and above). THIS IS NOT TRUE FOR SOLARIS 2.4. A user can change the values of the USER and in Sun's case LOGNAME. Also, if a user runs a program with the *sticky* bit set, then execs your Informix app, this will return the owner of the program exec'ing the app. Or if the app does a setuid (root owned and sticky bit set.) then it will return the user name the setuid performed. What INFORMIX does, is when an application is started, it checks the USER Name by getting the EUID or UID from the front end application. (In client server, the front end app must supply this info.) The data is stored in a pseudo field called user. (Sort of a *global* variable.) [Is there an official name for this?]. If you query for user on any table, it will supply you with the value stored in this *global* field. Most users tend to choose a system table since it will *always* exist. Again this value will contain the user name of the UID executing the front end. -Mikey