This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: add warning to os.getlogin
Type: Stage:
Components: Documentation Versions: Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, yoda_gh
Priority: normal Keywords:

Created on 2003-01-31 11:23 by yoda_gh, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (2)
msg14318 - (view) Author: Gernot Hillier (yoda_gh) Date: 2003-01-31 11:23
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! 
msg14319 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2003-02-03 15:42
Logged In: YES 
user_id=11375

Checked in to rev. 1.110 of libos.tex; thanks!
History
Date User Action Args
2022-04-10 16:06:20adminsetgithub: 37876
2003-01-31 11:23:33yoda_ghcreate