From c3306592fbb54fab0da44a8faaa8a1c6954537fd Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Thu, 18 Jan 2018 15:37:18 +0100 Subject: [feat] report missing polkit properly from main UI also refactor and move polkit_agent so that it does not depend on having bitmask on the path. --- src/leap/bitmask/vpn/helpers/__init__.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/leap/bitmask/vpn/helpers/__init__.py') diff --git a/src/leap/bitmask/vpn/helpers/__init__.py b/src/leap/bitmask/vpn/helpers/__init__.py index 8f8c1227..69b34e00 100644 --- a/src/leap/bitmask/vpn/helpers/__init__.py +++ b/src/leap/bitmask/vpn/helpers/__init__.py @@ -16,6 +16,7 @@ if IS_LINUX: from leap.bitmask.vpn.constants import OPENVPN_SYSTEM, OPENVPN_LOCAL from leap.bitmask.vpn.constants import POLKIT_SYSTEM, POLKIT_LOCAL from leap.bitmask.vpn.privilege import is_pkexec_in_system + from leap.bitmask.vpn.privilege import LinuxPolicyChecker def install(): helper_from = _config.get_bitmask_helper_path() @@ -40,6 +41,17 @@ if IS_LINUX: remove(POLKIT_LOCAL) remove(OPENVPN_LOCAL) + def privcheck(timeout=5): + has_pkexec = is_pkexec_in_system() + running = LinuxPolicyChecker.is_up() + if not running: + try: + LinuxPolicyChecker.get_usable_pkexec(timeout=timeout) + running = LinuxPolicyChecker.is_up() + except Exception: + running = False + return has_pkexec and running + def check(): helper = _is_up_to_date(_config.get_bitmask_helper_path(), BITMASK_ROOT_LOCAL, @@ -51,7 +63,7 @@ if IS_LINUX: _is_up_to_date(_config.get_bitmask_openvpn_path(), OPENVPN_LOCAL, "")) - return is_pkexec_in_system() and helper and polkit and openvpn + return helper and polkit and openvpn def _is_up_to_date(src, local, system): if src is None or not access(src, R_OK): @@ -72,6 +84,9 @@ elif IS_MAC: # XXX check if bitmask-helper is running return True + def privcheck(): + return True + def digest(path): with open(path, 'r') as f: -- cgit v1.2.3