From 12e68eab9de5fceeaa22f25cfeb21da56069e931 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Thu, 1 Mar 2018 21:08:25 +0100 Subject: [feat] increase verbosity on vpn checks to ease debugging --- src/leap/bitmask/vpn/helpers/__init__.py | 31 ++++++++++++++++++++++--------- src/leap/bitmask/vpn/service.py | 2 ++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/leap/bitmask/vpn/helpers/__init__.py b/src/leap/bitmask/vpn/helpers/__init__.py index df785057..9641e035 100644 --- a/src/leap/bitmask/vpn/helpers/__init__.py +++ b/src/leap/bitmask/vpn/helpers/__init__.py @@ -57,14 +57,27 @@ if IS_LINUX: running = LinuxPolicyChecker.is_up() except Exception: running = False - return has_pkexec and running + result = has_pkexec and running + log.debug('Privilege check: %s' % result) + return result def check(): - return ( - is_pkexec_in_system() and - _check_helper() and - _check_polkit_file_exist() and - _check_openvpn()) + pkexec = is_pkexec_in_system() + helper = _check_helper() + polkit = _check_polkit_file_exist() + openvpn = _check_openvpn() + if not pkexec: + log.error('No pkexec in system!') + if not helper: + log.error('No bitmask-root in system!') + if not polkit: + log.error('No polkit file in system!') + if not openvpn: + log.error('No openvpn in system!') + result = all([pkexec, helper, polkit, openvpn]) + if result is True: + log.debug('All checks passed') + return result def _check_helper(): log.debug('Checking whether helper exists') @@ -76,17 +89,17 @@ if IS_LINUX: if IS_SNAP: if os.path.isfile(BITMASK_ROOT_LOCAL): return True - log.error('cannot find bitmask-root in snap') + log.error('Cannot find bitmask-root in snap') return False helper_path_digest = digest(helper_path) if (_exists_and_can_read(BITMASK_ROOT_SYSTEM) and helper_path_digest == digest(BITMASK_ROOT_SYSTEM)): - log.debug('global bitmask-root: %s' % os.path.isfile(BITMASK_ROOT_SYSTEM)) + log.debug('Global bitmask-root: %s' % os.path.isfile(BITMASK_ROOT_SYSTEM)) return True if (_exists_and_can_read(BITMASK_ROOT_LOCAL) and helper_path_digest == digest(BITMASK_ROOT_LOCAL)): - log.debug('local bitmask-root: %s' % os.path.isfile(BITMASK_ROOT_LOCAL)) + log.debug('Local bitmask-root: %s' % os.path.isfile(BITMASK_ROOT_LOCAL)) return True log.debug('No valid bitmask-root found') diff --git a/src/leap/bitmask/vpn/service.py b/src/leap/bitmask/vpn/service.py index afa75e5e..78443323 100644 --- a/src/leap/bitmask/vpn/service.py +++ b/src/leap/bitmask/vpn/service.py @@ -116,6 +116,7 @@ class VPNService(HookableService): @defer.inlineCallbacks def start_vpn(self, domain=None): + self.log.debug('Starting VPN') self._cfg.set('autostart', True) autostart.autostart_app('on') @@ -234,6 +235,7 @@ class VPNService(HookableService): if expiry: expiry_ts = expiry.strftime('%Y-%m-%dT%H:%M:%SZ') ret['cert_expires'] = expiry_ts + self.log.debug('VPN check: %s' % str(ret)) return ret @defer.inlineCallbacks -- cgit v1.2.3