summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/vpn/_checks.py
blob: 3921d03b0bd748a02d26a878ca7bc532c8149e4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os

from leap.common.config import get_path_prefix


# TODO use privilege.py module, plenty of checks in there for pkexec and
# friends.

class ImproperlyConfigured(Exception):
    pass


def is_service_ready(provider):
    _has_valid_cert(provider)
    return True


def get_vpn_cert_path(provider):
    return os.path.join(get_path_prefix(),
                        'leap', 'providers', provider,
                        'keys', 'client', 'openvpn.pem')


def _has_valid_cert(provider):
    cert_path = get_vpn_cert_path(provider)
    has_file = os.path.isfile(cert_path)
    if not has_file:
        raise ImproperlyConfigured('Missing VPN certificate')