os.getlogin() Error

Wildman best_lay at yahoo.com
Thu May 4 19:50:32 EDT 2017


On Fri, 05 May 2017 08:31:15 +1000, Chris Angelico wrote:

> On Fri, May 5, 2017 at 8:18 AM, Wildman via Python-list
> <python-list at python.org> wrote:
>> 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.
> 
> Ah, okay. I wonder if you can do the same thing? Just before you
> invoke pkexec, create an environment variable with the current user
> credentials. Then pkexec back to yourself, and look in the
> environment.
> 
> ChrisA

I'm afraid that won't work.  The user environment is different
than root.  A different set of variables.  However you have
given me a possible workaround.  You can't create a variable
for root unless you are root so that approach is out.  But
it might be possible to create the variable for the user
and access it as root.  I don't have a lot of experience
using os.environ, but I am going to at it closer.

Thanks.

-- 
<Wildman> GNU/Linux user #557453
The cow died so I don't need your bull!



More information about the Python-list mailing list