Issue584566
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.
Created on 2002-07-21 17:29 by rlblyler, last changed 2022-04-10 16:05 by admin. This issue is now closed.
Messages (4) | |||
---|---|---|---|
msg11652 - (view) | Author: Robert Blyler (rlblyler) | Date: 2002-07-21 17:29 | |
The os.getlogin() fails with a no-such file. I originally reported this bug to the gentoo bug tracking system see: http://bugs.gentoo.org/show_bug.cgi?id=4647 The issue seems to be that some xterminals ( gterm in this case ) do not register themselves with utmp, which this function uses. I have two workarounds, one of reverting back to using: os.getenv('USER') and another for: print pwd.getpwuid(os.geteuid())[0] This seems to violate the portability of os.getlogin() though, and was wondering if a different internal implementation should be used. I would expect that at any rate it shouldn't cause a program to crash. The following is the original error: Traceback (most recent call last): File "./trilliji.py", line 25, in ? main() File "./trilliji.py", line 16, in main Connections = TriCon() File "./clsTriCon.py", line 16, in __init__ self.login_user=os.getlogin() OSError: [Errno 2] No such file or directory |
|||
msg11653 - (view) | Author: Jeremy Hylton (jhylton) | Date: 2002-07-24 15:24 | |
Logged In: YES user_id=31392 This is not a Python bug. Python is just calling the platform getlogin(). On my Linux box, a C program that calls getlogin() reports exactly the same error. It returns NULL and sets errno to ENOENT, which strerror() converts to "No such file or directory." The man page for getlogin on Linux says: For most purposes, it is more useful to use the environ ment variable LOGNAME to find out who the user is. This is more flexible precisely because the user can set LOG NAME arbitrarily. The same man page describes cuserid() and says: Nobody knows precisely what cuserid() does - avoid it in portable programs - avoid it altogether - use getp wuid(geteuid()) instead, if that is what you meant. DO NOT USE cuserid(). |
|||
msg11654 - (view) | Author: Robert Blyler (rlblyler) | Date: 2002-07-25 02:11 | |
Logged In: YES user_id=36845 Can you explain then why python doesn't implement that method to determine the logged in user? If it is so bad either why does it exist or why isn't it implemented better? |
|||
msg11655 - (view) | Author: Michael Hudson (mwh) | Date: 2002-07-25 14:53 | |
Logged In: YES user_id=6656 the os module isn't about providing polite wrappers for sys/library calls. it's about thin wrappers so you can read the system manpages to find out why you don't want to use them <wink>. print pwd.getpwuid(os.geteuid())[0] is the best answer I know of. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:05:31 | admin | set | github: 36915 |
2002-07-21 17:29:08 | rlblyler | create |