I wrote a Linux only GUI program using Tk that reports various system information using a tabbed Notebook. I have tested the program on Debian, SoldyX and MX-15 and the program runs perfectly.
I tried testing on Mint and Ubuntu and the program would crash. The GUI would appear briefly and disappear. On Ubuntu a crash report was created so I was able to figure out what was going on. It had the traceback and showed that os.getlogin threw an error. This is from the crash report: PythonArgs: ['/opt/linfo-tk/linfo-tk.py'] Traceback: Traceback (most recent call last): File "/opt/linfo-tk/linfo-tk.py", line 1685, in <module> app = Window(root) File "/opt/linfo-tk/linfo-tk.py", line 1393, in __init__ txt = function() File "/opt/linfo-tk/linfo-tk.py", line 316, in userinfo user = os.getlogin() OSError: [Errno 25] Inappropriate ioctl for device The program installs using the Debian package system (.deb) and an entry is created in the Applications Menu. The strange thing is that the crash only occurs when the program is run from the menu. If I open a terminal and run the program from there, the program runs fine. I found a little info on the web about this but it was not clear whether it is a bug in Linux or a bug in the os module. I also found a couple of work-arounds but neither of them will work for my purposes. user = pwd.getpwuid(os.getuid())[0] user = getpass.getuser() I will try to explain... The program reports system information based on the user's name. Things such as passwd, groups and shadow info. However, the program must have elevated privileges to get the shadow info so the program has the option to 'restart as root' so the shadow information will be obtainable. If the program is restarting as root, the work-arounds report the user as 'root'. Then the system information for passwd, groups and shadow will be reported for 'root' and not the user that ran the program. The actual user name that ran the program is needed for the program to report correct information. It seems that only os.getlogin() reports the true user name no matter if the program is run as a normal user or restarted as root. Is there a way to get the actual user name or is there a fix or a better work-around for the os.getlogin() function? -- <Wildman> GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list