From 87db0130f83b071845258a073c62460ccdf6efe5 Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 13 Feb 2010 00:54:27 +0100 Subject: fixed #46: wrong username displayed when using su --- TODO | 2 +- ranger/gui/widgets/titlebar.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 3366ca4e..9a5a4675 100644 --- a/TODO +++ b/TODO @@ -56,7 +56,7 @@ Bugs (X) #31 10/01/06 ^C breaks cd-after-exit by stopping sourced shell script ( ) #40 10/01/17 freeze with unavailable sshfs (X) #41 10/01/17 capital file extensions are not recognized - ( ) #46 10/01/19 old username displayed after using su + (X) #46 10/01/19 old username displayed after using su (X) #49 10/01/19 fix unit tests :'( ( ) #52 10/01/23 special characters in tab completion (X) #54 10/01/23 max_dirsize_for_autopreview not working diff --git a/ranger/gui/widgets/titlebar.py b/ranger/gui/widgets/titlebar.py index 43729947..7c164ae9 100644 --- a/ranger/gui/widgets/titlebar.py +++ b/ranger/gui/widgets/titlebar.py @@ -53,9 +53,12 @@ class TitleBar(Widget): self.result = bar.combine() def _get_left_part(self, bar): - import socket, os + import socket, os, pwd - username = os.getenv('USER') + try: + username = pwd.getpwuid(os.geteuid()).pw_name + except: + username = "???" if username == 'root': clr = 'bad' else: -- cgit 1.4.1-2-gfad0