SUGGEST: os.getuser()
Fred L. Drake, Jr.
fdrake at acm.org
Fri Jan 21 11:54:58 EST 2000
Gerrit Holl writes:
> So getpwuid() is never safe? But in my program, I *also* need the
> comment field. So if there are multiple uids the same, I can't get
> the full name?
It sounds like you should use os.getlogin() (in the CVS version) to
get the actual login name and perform the lookup that way. To be
*really* safe, use both getlogin() *and* getuid(). ;) Seriously,
there should be only one line in /etc/passwd that matches the result
of os.getlogin(), but the existing getpass.getuser() should be fine
for most everyone.
Perhaps *that* should be modified to use getlogin() when available,
in preference to pwd.getpwuid(os.getuid())[0] ?
-Fred
--
Fred L. Drake, Jr. <fdrake at acm.org>
Corporation for National Research Initiatives
More information about the Python-list
mailing list