Re: getting login name in 4GL
Posted in 1996
Cheryl Kendricks wrote: > > I did not say whoami was the answer. You should use an universal UNIX > eviromnent variable. Are you telling me UNIX does not have one for user > id? whoami is just the only one I know (which does not say a whole lot), > Yet, UNIX must have at least one that is always set! I've never had to > deal with this in the mainframe world. If UNIX does not have a universal set of > environment vars then I say pooh on it! Pooh on it? My such language from a pristine individual! 8^() ;-) Seriously, Depending on your shell environment you can use $LOGNAME, $USER , etc ... In ksh, $LOGNAME is supposed to be a protected shell variable. ie read only. On Sun, Solaris 2.4, this is NOT the case! The ONLY way to get the correct information on ALL variations of UNIX, is to get both the effective user id, and the real user id. (They can be different.) This won't give you the id of the user who logged in, but the user id when the program is being accessed. Using the *sticky bit* or a set-uid program before execution will change this. If you are using 4gl, then build a runner to a c program which uses various generic system calls like getuid. Once you have the uid, you can get the other information from the passwd file. (/etc/passwd will contain all the non secure information. In NIS, you may need to use different system calls. I'll check in to this since I need to know for sure.) -Mikey = Just some guy who makes it a hobby of lying face down in the gutter ;-)