Bug 171631 - Python function os.getlogin fails in konsole
Summary: Python function os.getlogin fails in konsole
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 2.1
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-25 02:58 UTC by Jonathan Thomas
Modified: 2011-03-04 21:19 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.