def __call__(self): current_version = self._version(_config.get_bitmask_helper_path()) _sys = constants.BITMASK_ROOT_SYSTEM _sys_version = 0 _local = constants.BITMASK_ROOT_LOCAL _local_version = 0 if IS_SNAP: return _local if os.path.isfile(_sys): _sys_version = self._version(_sys) if os.path.isfile(_local): _local_version = self._version(_local) if _sys_version == current_version: return _sys elif _local_version == current_version: return _local elif _sys_version != 0 and _sys_version >= _local_version: return _sys elif _local_version != 0: return _local else: return 'bitmask-root'
def _check_helper(): log.debug('Checking whether helper exists') helper_path = _config.get_bitmask_helper_path() if not _exists_and_can_read(helper_path): log.debug('Cannot read helpers') return True if IS_SNAP: if os.path.isfile(BITMASK_ROOT_SNAP): return True 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)) 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)) return True log.debug('No valid bitmask-root found') return False
def install(): helper_from = _config.get_bitmask_helper_path() polkit_from = _config.get_bitmask_polkit_policy_path() openvpn_from = _config.get_bitmask_openvpn_path() sbin = '/usr/local/sbin' if not os.path.isdir(sbin): os.makedirs(sbin) copyfile(helper_from, BITMASK_ROOT_LOCAL) chmod(BITMASK_ROOT_LOCAL, 0744) copyfile(polkit_from, POLKIT_LOCAL) if STANDALONE: copyfile(openvpn_from, OPENVPN_LOCAL) chmod(OPENVPN_LOCAL, 0700)
def install(): helper_from = _config.get_bitmask_helper_path() polkit_from = _config.get_bitmask_polkit_policy_path() copyfile(helper_from, helper_to) chmod(helper_to, 0744) copyfile(polkit_from, polkit_to)