policycoreutils/chcat: Add a fallback in case os.getlogin() returns nothing
PATCH 1/1 policycoreutils/chcat: Add a fallback in case os.getlogin() returns nothing
From: Laurent Bigonville <[email protected]>
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(-)
policycoreutils/scripts/chcat +4 -1
@@ -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:
Signature · 1 line
2.6.4
Steve Lawrence
AppliedQuoted 7 lines · Laurent Bigonville
From: Laurent Bigonville <[email protected]>
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.
Applied. Thanks.
Also, in the future, please add a Signed-off-by line.
Quoted 21 lines
--- policycoreutils/scripts/chcat | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)policycoreutils/scripts/chcat +4
-1@@ -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: