Re: getting login name in 4GL
Posted in 1996
In article <319CD472.5EE8@informix.com>, Kevin Franden <kevinf@informix.com> writes:
> 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!
> >
> > On Tue, 14 May 1996, Chris Drauch wrote:
> >
> > } Cheryl Kendricks wrote
> > } >
> > } >I'm not in anyway a UNIX expert. But what is wrong with just using what is
> > } >returned from the whoami command. To have control you could even set some
> > } >var SYSUSERID='whoami' at the SYSTEM DEFAULT LOGIN SHELL.
> > }
> > } One some systems you will maybe find 'whoami', on some 'who am i' or just
> > } 'who'. There are more risks using a external command, script or shell
> > } variable than lib calls.
> > }
>
>
> Well, You could always read the USER or LOGNAME environment vars. These are on
> nearly every *nix _but_ are not 100% portable, specifically between BSD and ATT.
> (BSD likes to use USER and ATT likes to use LOGNAME). In addition, if the shell
> does not make these vars "readonly" the can be made to lie to your program. Not
> a desirable thing.
>
> 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.
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Kevin Franden Informix Software, Inc.
> 16011 College Blvd
> kevinf@informix.com Lenexa, KS. 66219
> uunet!infmx!kevinf
>
> #include <patchlevel.h>
> fprintf(DISCLAIMER,"I said what I said.\\n");
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
> You only live once but if you do it right, once is enough
> Carpe Diem
How do you do this if you are client/servering? A trigger/stored proc
I suppose, but Are you sure that the sqlexec server process is running
with the users uid and not root or informix?
Surely
select user from systables where tabid=1
or any other table guaranteed to have a row
is more trustworthy than a script or environment variable?
If we can't trust the database to get the username right aren't we taking
paranoia a little too far?
----------------------------------------------------------------------
David Paulo, InForm Group Ltd.,PO Box 1444, Wellington, New Zealand.
Ph: +64 4 472 0996 Fax: +64 4 473 2407 Email: david@inform.co.nz
= What would you do if you knew that you could not fail =
----------------------------------------------------------------------