aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bigonville <bigon@bigon.be>2015-12-13 23:40:40 +0100
committerSteve Lawrence <slawrence@tresys.com>2015-12-17 08:56:01 -0500
commit7d8f5ce9b8d3e7d0fbd27c39a6f41e578a675ce6 (patch)
treeea26fdde4028a3a2dc8bf7c77293f6c77e781c73
parentf2a8ae91725c89bac108f35e3640a222a7e9be2d (diff)
downloadselinux-7d8f5ce9b8d3e7d0fbd27c39a6f41e578a675ce6.tar.gz
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.
-rwxr-xr-xpolicycoreutils/scripts/chcat5
1 files changed, 4 insertions, 1 deletions
diff --git a/policycoreutils/scripts/chcat b/policycoreutils/scripts/chcat
index ec527e55..472785cb 100755
--- a/policycoreutils/scripts/chcat
+++ b/policycoreutils/scripts/chcat
@@ -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: