diff options
author | Ruben Pollan <meskio@sindominio.net> | 2017-09-18 19:53:17 +0200 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2017-09-20 17:56:49 +0200 |
commit | 79e9f3c69b4eb061490d6a12a52888abc429542e (patch) | |
tree | bab13194d73dc75218a1575d52888c0f563e508c /src/leap/bitmask/vpn/_checks.py | |
parent | d0e4444555df79978aed5cd6c9548e2fd1c63936 (diff) |
[feat] detect if pkexec is present in the system
Check it before starting the vpn.
- Resolves: #8895
Diffstat (limited to 'src/leap/bitmask/vpn/_checks.py')
-rw-r--r-- | src/leap/bitmask/vpn/_checks.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/leap/bitmask/vpn/_checks.py b/src/leap/bitmask/vpn/_checks.py index 6c089628..c6117d0d 100644 --- a/src/leap/bitmask/vpn/_checks.py +++ b/src/leap/bitmask/vpn/_checks.py @@ -2,13 +2,14 @@ import os from datetime import datetime from time import mktime +from twisted.logger import Logger +from leap.bitmask.vpn.privilege import is_pkexec_in_system, NoPkexecAvailable from leap.common.certs import get_cert_time_boundaries from leap.common.config import get_path_prefix +log = Logger() -# TODO use privilege.py module, plenty of checks in there for pkexec and -# friends. class ImproperlyConfigured(Exception): pass @@ -18,6 +19,10 @@ def is_service_ready(provider): if not _has_valid_cert(provider): raise ImproperlyConfigured('Missing VPN certificate') + if not is_pkexec_in_system(): + log.warn('System has no pkexec') + raise NoPkexecAvailable() + return True @@ -40,10 +45,12 @@ def _has_valid_cert(provider): cert_path = get_vpn_cert_path(provider) has_file = os.path.isfile(cert_path) if not has_file: + log.warn("VPN cert not present for %s" % (provider,)) return False expiry = cert_expires(provider) if datetime.now() > expiry: + log.warn("VPN cert expired for %s" % (provider,)) return False return True |