summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/vpn/privilege.py
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2017-05-19 14:54:51 +0200
committerRuben Pollan <meskio@sindominio.net>2017-05-22 12:56:22 +0200
commit35d2f5662c6f03480f3f6f9ef9092757447361ed (patch)
tree8ee163148918f1b75e5e064c7cf46bb3f1ae15df /src/leap/bitmask/vpn/privilege.py
parent9b415b6423c7dd18fe9ffa302c3343dfa2314619 (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.py32
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):