euser - display the effective user name, SysV-ish

John F. Haugh II jfh at rpp386.Dallas.TX.US
Sat Jul 8 15:49:46 AEST 1989


In article <14448 at bfmny0.UUCP> tneff at bfmny0.UUCP (Tom Neff) writes:
>If you need a FAST way to generate the name of your current effective
>user (including the effects of su(1) etc), this works.  It's not fancy.
>Obviously it has to read /etc/passwd.  Feel free to hack and pass
>around.

>X	while (fgets(line, sizeof(line), pass) != NULL)

This is not a very good idea.  You make assumptions about the
password file which probably won't be holding true for too many
more releases of UNIX.

getpwuid() is going to be your best bet.  It should be hoped
that your local software vendor took the time to implement
getpwuid() in an efficient manner; such as using YP or ndbm or
whatever services are available.  In a distributed environment
the password file may not even reside on your machine completely.
-- 
John F. Haugh II                        +-Quote of the month club: ------------
VoiceNet: (512) 832-8832   Data: -8835  | "Computer security is to information
InterNet: jfh at rpp386.cactus.org         |  control as a chastity belt is to
UucpNet : <backbone>!bigtex!rpp386!jfh  +- birth control"    -- Doug Steves  --



More information about the Alt.sources.d mailing list