diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2017-05-19 14:54:51 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2017-05-22 12:56:22 +0200 |
commit | 35d2f5662c6f03480f3f6f9ef9092757447361ed (patch) | |
tree | 8ee163148918f1b75e5e064c7cf46bb3f1ae15df /src/leap/bitmask/vpn/privilege.py | |
parent | 9b415b6423c7dd18fe9ffa302c3343dfa2314619 (diff) |
[feat] port the polkit agent launcher
this commit is porting the polkit launcher from the legacy bitmask
client. if no polkit authentication agent is running, it will try to run
one that is found in the system.
- Resolves: #8836
Diffstat (limited to 'src/leap/bitmask/vpn/privilege.py')
-rw-r--r-- | src/leap/bitmask/vpn/privilege.py | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/leap/bitmask/vpn/privilege.py b/src/leap/bitmask/vpn/privilege.py index 2576877a..4617aedf 100644 --- a/src/leap/bitmask/vpn/privilege.py +++ b/src/leap/bitmask/vpn/privilege.py @@ -169,26 +169,20 @@ class LinuxPolicyChecker(PolicyChecker): @classmethod def launch(self): """ - Tries to launch policykit + Tries to launch policykit. """ - env = None - if STANDALONE: - # This allows us to send to subprocess the environment configs that - # works for the standalone bundle (like the PYTHONPATH) - env = dict(os.environ) - # The LD_LIBRARY_PATH is set on the launcher but not forwarded to - # subprocess unless we do so explicitly. - env["LD_LIBRARY_PATH"] = os.path.abspath("./lib/") - try: - # We need to quote the command because subprocess call - # will do "sh -c 'foo'", so if we do not quoute it we'll end - # up with a invocation to the python interpreter. And that - # is bad. - log.debug('Trying to launch polkit agent') - subprocess.call(["python -m leap.bitmask.util.polkit_agent"], - shell=True, env=env) - except Exception: - log.failure('Error while launching vpn') + if not self.is_up(): + try: + # We need to quote the command because subprocess call + # will do "sh -c 'foo'", so if we do not quoute it we'll end + # up with a invocation to the python interpreter. And that + # is bad. + log.debug('Trying to launch polkit agent') + subprocess.call( + ["python -m leap.bitmask.vpn.helpers.linux.polkit_agent"], + shell=True) + except Exception: + log.failure('Error while launching vpn') @classmethod def is_up(self): |