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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Laurent Bigonville <bigon@xxxxxxxx>

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.
---
 policycoreutils/scripts/chcat | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/policycoreutils/scripts/chcat b/policycoreutils/scripts/chcat
index ec527e5..472785c 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:
-- 
2.6.4

_______________________________________________
Selinux mailing list
Selinux@xxxxxxxxxxxxx
To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx.
To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.



[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux