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

SourceForge.net noreply@sourceforge.net
Fri, 31 Jan 2003 03:23:33 -0800


Bugs item #678077, was opened at 2003-01-31 12: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: Open
Resolution: None
Priority: 5
Submitted By: Gernot Hillier (yoda_gh)
Assigned to: Nobody/Anonymous (nobody)
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! 

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

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