On Fri, 05 May 2017 07:46:32 +1000, Chris Angelico wrote: > On Fri, May 5, 2017 at 6:03 AM, Wildman via Python-list > <python-list@python.org> wrote: >> 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? > > That depends on exactly how the program "restarts as root". One very > common way to do this is to invoke itself through sudo(1). If that's > how you're flipping yourself to root, check os.environ["SUDO_USER"] or > os.environ["SUDO_UID"], both of which will be set by sudo before it > invokes the program. > > ChrisA
I am using pkexec to restart so $SUDO_USER is not set. For some reason sudo, su and su-to-root will freeze the first instance of the program and not let it close until the second instance closes. I have tried every method I can find to launch them and pkexec is the only one that works correctly. Thanks for the reply. -- <Wildman> GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list