policycoreutils/chcat: Add a fallback in case os.getlogin() returns nothing

Some teminal emulators (like the latest version of gnome-terminal) are
not setting entries in the utmp file, this leads getlogin() to return an
empty string.

Fallback to the name of the user running the chcat process.
This commit is contained in:
Laurent Bigonville 2015-12-13 23:40:40 +01:00 committed by Steve Lawrence
parent f2a8ae9172
commit 7d8f5ce9b8

View File

@ -372,7 +372,10 @@ def listcats():
def listusercats(users):
if len(users) == 0:
users.append(os.getlogin())
try:
users.append(os.getlogin())
except:
users.append(pwd.getpwuid(os.getuid()).pw_name)
verify_users(users)
for u in users: