* [PATCH] policycoreutils/chcat: Add a fallback in case os.getlogin() returns nothing
@ 2015-12-13 22:40 Laurent Bigonville
2015-12-17 14:16 ` Steve Lawrence
0 siblings, 1 reply; 2+ messages in thread
From: Laurent Bigonville @ 2015-12-13 22:40 UTC (permalink / raw)
To: selinux
From: Laurent Bigonville <bigon@bigon.be>
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] policycoreutils/chcat: Add a fallback in case os.getlogin() returns nothing
2015-12-13 22:40 [PATCH] policycoreutils/chcat: Add a fallback in case os.getlogin() returns nothing Laurent Bigonville
@ 2015-12-17 14:16 ` Steve Lawrence
0 siblings, 0 replies; 2+ messages in thread
From: Steve Lawrence @ 2015-12-17 14:16 UTC (permalink / raw)
To: Laurent Bigonville, selinux
On 12/13/2015 05:40 PM, Laurent Bigonville wrote:
> From: Laurent Bigonville <bigon@bigon.be>
>
> 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.
> ---
> 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:
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-17 14:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-13 22:40 [PATCH] policycoreutils/chcat: Add a fallback in case os.getlogin() returns nothing Laurent Bigonville
2015-12-17 14:16 ` Steve Lawrence
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.