[Python-bugs-list] [ python-Bugs-678077 ] add warning to os.getlogin

SourceForge.net noreply@sourceforge.net
Mon, 03 Feb 2003 07:42:22 -0800


Bugs item #678077, was opened at 2003-01-31 06:23
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=678077&group_id=5470

Category: Documentation
Group: Python 2.2.2
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Gernot Hillier (yoda_gh)
>Assigned to: A.M. Kuchling (akuchling)
Summary: add warning to os.getlogin

Initial Comment:
I experienced problems when using os.getlogin(). It doesn't work for 
exmaple after doing a "su". It still reports the old login. 
 
Also "man 3 getlogin" tells me on GNU/Linux (SuSE 8.1): 
 
"Unfortunately,  it  is  often  rather easy to fool getlogin().  
Sometimes it does not work at all, because some program messed up 
the utmp file. Often, it gives only the first 8 characters of the login 
name. The user currently logged in on the controlling tty of our 
program need not be the user  who  started it.  Avoid getlogin() for 
security-related purposes. 
 
Nobody  knows  precisely  what cuserid() does - avoid it in portable 
programs - avoid it altogether - use getpwuid(geteuid()) instead, if 
that is what you meant.  DO NOT USE cuserid()" 
 
It would be nice if you could add some warning to the documentation 
of Python's os.getlogin() telling the user it's better to use 
"pwd.getpwuid(os.getuid())[0]". That's at least what I do now and it 
works as expected. 
 
TIA! 

----------------------------------------------------------------------

>Comment By: A.M. Kuchling (akuchling)
Date: 2003-02-03 10:42

Message:
Logged In: YES 
user_id=11375

Checked in to rev. 1.110 of libos.tex; thanks!

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=678077&group_id=5470