On Fri, 05 May 2017 09:58:02 +1000, Chris Angelico wrote: > On Fri, May 5, 2017 at 9:50 AM, Wildman via Python-list > <python-list@python.org> wrote: >> 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. > > When you start a subprocess, it inherits your environment. So you can > create an environment variable for yourself, then start the other > process.
I solved this problem by passing the user name to the second instance as a command line argument. Works perfectly. It escapes me why I didn't think of this sooner. I solved the os.login problem by not using os.login, since I no longer need it. :-) > But read Cameron's cautionary notes and basically just don't do this. > > ChrisA It has been my experience that Linux users tend to be a little more conscious of security matters and know what the implications are when doing anything as root. I expect the user will know the risks if they choose to restart the program as root. I believe in user choice. Thanks again for your replies. -- <Wildman> GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list