I'm executing a python script as root with pkexec and I'm using working_dir = os.getenv('HOME')
to get the username but it always returns root
instead of test1
which is the current user.
How can I get the user that ran pkexec instead?
I already tried print os.environ["SUDO_USER"]
but that fails since it's not being executed directly with sudo. I am on trusty now but behaves the same in 16.04.
I fixed it like this: