Bug 171631

Summary: Python function os.getlogin fails in konsole
Product: [Applications] konsole Reporter: Jonathan Thomas <echidnaman>
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: normal CC: robertknight
Priority: NOR    
Version: 2.1   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Jonathan Thomas 2008-09-25 02:58:05 UTC
Version:           2.1 (using 4.1.1 (KDE 4.1.1), Kubuntu packages)
Compiler:          cc
OS:                Linux (i686) release 2.6.26-5-generic

Originally from https:/launchpad.net/bugs/155508

Python's os.getlogin() function fails when it is runs under Konsole/any embedded Konsole. It does not fail under virtual consoles, xterm, or gnome's terminal.
To reproduce, enter the following in Konsole:

python
import os; os.getlogin()

This will result in:
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OSError: [Errno 2] No such file or directory

Expected result would be for your username to be returned.
Comment 1 Robert Knight 2008-09-25 12:12:07 UTC
Hi,

This appears to relate to the fact that Konsole does not update utmp when it creates a new session.  IIRC this was disabled in the lead-up to KDE 4.0 because of problems in the kpty library which I should really fix.

In gnome-terminal you can see the same result if the "Update login records when command is launched" option is unchecked in the 'Title and Command' tab in the settings dialog.
Comment 2 Robert Knight 2008-09-25 12:13:31 UTC
As a side note, there is a bug in Konsole here but even so os.getlogin() ought to fail more gracefully, since it is easily possible for a terminal not to update the login records.
Comment 3 Kurt Hindenburg 2011-03-04 21:19:29 UTC
With KDE 4.6.x it works in Konsole/yakuake/konq.