summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2017-09-14 00:16:19 +0200
committerRuben Pollan <meskio@sindominio.net>2017-09-15 23:40:05 +0200
commitc27a6b6c3ef8b2b529b884d261b2acabf6322077 (patch)
treea781224428da5fb795608d7ecf22a3263394b598 /src
parentbf7920abcceb0651ab536b3a7268cc87b886469e (diff)
[feat] wait up to 20 seconds for polkit to be launched
- Related: #9012
Diffstat (limited to 'src')
-rw-r--r--src/leap/bitmask/vpn/privilege.py34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/leap/bitmask/vpn/privilege.py b/src/leap/bitmask/vpn/privilege.py
index 54065a81..458f690d 100644
--- a/src/leap/bitmask/vpn/privilege.py
+++ b/src/leap/bitmask/vpn/privilege.py
@@ -109,23 +109,29 @@ class LinuxPolicyChecker(object):
:returns: a list of the paths where pkexec is to be found
:rtype: list
"""
- if self._is_pkexec_in_system():
- if not self.is_up():
- self.launch()
- time.sleep(2)
- if self.is_up():
- pkexec_possibilities = which(self.PKEXEC_BIN)
- if not pkexec_possibilities:
- raise Exception("We couldn't find pkexec")
- return pkexec_possibilities
- else:
- log.warn('No polkit auth agent found. pkexec ' +
- 'will use its own auth agent.')
- raise NoPolkitAuthAgentAvailable()
- else:
+ if not self._is_pkexec_in_system():
log.warn('System has no pkexec')
raise NoPkexecAvailable()
+ if not self.is_up():
+ self.launch()
+ seconds = 0
+ while not self.is_up():
+ if seconds >= 20:
+ log.warn('No polkit auth agent found. pkexec ' +
+ 'will use its own auth agent.')
+ raise NoPolkitAuthAgentAvailable()
+
+ # XXX: sleep()!!!! we should do it the twisted way
+ time.sleep(1)
+ seconds += 1
+
+ pkexec_possibilities = which(self.PKEXEC_BIN)
+ if not pkexec_possibilities:
+ raise Exception("We couldn't find pkexec")
+
+ return pkexec_possibilities
+
@classmethod
def launch(self):
"""