Re: getting login name in 4GL
Posted in 1996
Tim Schaefer wrote:
>
> Cheryl Kendricks wrote:
> >
> > Tim if you are trying to get login information for use of Informix 7.x DB,
> > then access the sysmaster DB! IF it is not there you have NO ONLINE or the
[Stuff Cut]
Actually a poster put a select statement, something like:
' SELECT user FROM systables WHERE tabname = "systables" '
While this works, you should be aware of the following:
1) user is not a defined element of a table.
2) you can point to any table, request a unique user and you will get
the
user value.
So, you could say:
SELECT unique user FROM (Insert your favorite system table here)Most people would recommend that you use a common system table. (You
know that it
is always there ;-)
> Sorry,
>
> But I don't depend on the data base for login information. I learned this
> concept a while back. UNIX is the host environment, and I'd trust UNIX
> before I trust software that for the most part does stuff I don't have a
> CLUE what it's doing. I really like INFORMIX products, but let's not
> get carried away here.
In UNIX, the current username is stored in $LOGNAME. LOGNAME is a read
only shell variable. I tested this for /bin/ksh and /bin/sh. You cannot
change this variable, hence it should be considered reliable. LOGNAME
represents the user name of the login account.
>
> The data base user information is one step farther away from just going to
> UNIX and getting the login. How do YOU know just how current the data
> base information is?
Informix, when the front end starts, gets the effective UID and user
name.It does not use any
of the shell variables. I just tested this. First I tried to change all
the variables I could.
Informix still picked my login name correctly.
I then ran a setuid program I had written. This program changes the
effective uid of the
user and execs a shell.
From the shell I called dbaccess and ran the SQL statement. It picked up
the username
of the user I set myself to. The variable $LOGNAME still represented me.
So if you want the Login Name use $LOGNAME. If you want to see what the
effective user id running your program, use the "global" username.
IMHO- I'd trust Informix on this one. (God. Imagine me saying that ;-)
For you to do this,
you would need to exec a shell, get the UID, then do a lookup against
the passwd file.
All really simple C function calls, but you will have to write the
runner, load and link it
to your app. I'd say a select statement is much easier.
-Mikey
"Hey wadda ya expect? Another great tip from your uncle lou."
#include<std.disclaimer.h>