mirror of
https://github.com/topjohnwu/selinux.git
synced 2024-11-28 14:00:45 +00:00
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:
parent
f2a8ae9172
commit
7d8f5ce9b8
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user