Skip to contentSkip to conversation

chcat is using getlogin() function that sometimes returns null/empty string

DISCUSSION Laurent Bigonville 2 participants 2 messages Dec 7, 2015 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hi,

So apparently gnome-terminal developers have decided to stop updating utmp[0] file and this is breaking chcat -Ll with the following error:

Traceback (most recent call last):
File "/usr/bin/chcat", line 409, in <module>
sys.exit(listusercats(cmds))
File "/usr/bin/chcat", line 352, in listusercats
users.append(os.getlogin())
OSError: [Errno 2] No such file or directory

getlogin(3) manpage suggest to rely on the LOGNAME environment variable, so maybe chcat should fallback to this if getlogin() is not returning anything?

Cheers,

Laurent Bigonville

[0] https://bugzilla.gnome.org/show_bug.cgi?id=747046

#1 lore raw
Quoted 16 lines · Laurent Bigonville

Hi,

So apparently gnome-terminal developers have decided to stop updating utmp[0] file and this is breaking chcat -Ll with the following error:

Traceback (most recent call last):
File "/usr/bin/chcat", line 409, in <module>
sys.exit(listusercats(cmds))
File "/usr/bin/chcat", line 352, in listusercats
users.append(os.getlogin())
OSError: [Errno 2] No such file or directory

getlogin(3) manpage suggest to rely on the LOGNAME environment variable, so maybe chcat should fallback to this if getlogin() is not returning anything?

Quoted 5 lines

Cheers,

Laurent Bigonville

[0] https://bugzilla.gnome.org/show_bug.cgi?id=747046

Maybe just use:
pwd.getpwuid(os.getuid()).pw_name