diff options
author | Sylvain Pineau <sylvain.pineau@canonical.com> | 2020-04-03 10:41:36 +0200 |
---|---|---|
committer | Sylvain Pineau <sylvain.pineau@canonical.com> | 2020-04-03 10:41:36 +0200 |
commit | 6f896de993d12f7fddea9dcf3ff180d396879592 (patch) | |
tree | 2398832a89b65cde30fceecd2865024859446c56 /bin | |
parent | 7a722231a0795a5bb56416951efd28511b3e48a3 (diff) |
bin:pm_test: Use the NORMAL_USER en var when invoked via remote
SUDO_UID is not available since the slave service is a systemd unit running as root
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/pm_test | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/bin/pm_test b/bin/pm_test index b03e680..3dcdf28 100755 --- a/bin/pm_test +++ b/bin/pm_test @@ -36,11 +36,13 @@ def main(): sys.exit(1) # Obtain name of the invoking user. - uid = os.getenv('SUDO_UID') or os.getenv('PKEXEC_UID') - if not uid: - sys.stderr.write('Unable to determine invoking user\n') - sys.exit(1) - username = pwd.getpwuid(int(uid)).pw_name + username = os.getenv('NORMAL_USER') + if not username: + uid = os.getenv('SUDO_UID') or os.getenv('PKEXEC_UID') + if not uid:q + sys.stderr.write('Unable to determine invoking user\n') + sys.exit(1) + username = pwd.getpwuid(int(uid)).pw_name LoggingConfiguration.set(args.log_level, args.log_filename, args.append) logging.debug('Invoking username: %s', username) |