def get_installed_policy(root="/"): try: path = root + selinux.selinux_binary_policy_path() policies = glob.glob("%s.*" % path) policies.sort(key=policy_sortkey) return policies[-1] except: pass raise ValueError(_("No SELinux Policy installed"))
def __get_installed_policy(): try: path = selinux.selinux_binary_policy_path() policies = glob.glob ("%s.*" % path ) policies.sort() return policies[-1] except: pass raise ValueError(_("No SELinux Policy installed"))
def _potential_policies(): """Generate a list of potential policies to use.""" # try libselinux for current policy if selinux.selinuxfs_exists(): yield selinux.selinux_current_policy_path() # otherwise look through the supported policy versions base_policy_path = selinux.selinux_binary_policy_path() for version in range(qpol.QPOL_POLICY_MAX_VERSION, qpol.QPOL_POLICY_MIN_VERSION-1, -1): yield "{0}.{1}".format(base_policy_path, version)
def _potential_policies(): """Generate a list of potential policies to use.""" # Start with binary policies in the standard location base_policy_path = selinux.selinux_binary_policy_path() for version in range(qpol.QPOL_POLICY_MAX_VERSION, qpol.QPOL_POLICY_MIN_VERSION - 1, -1): yield "{0}.{1}".format(base_policy_path, version) # Last chance, try selinuxfs. This is not first, to avoid # holding kernel memory for a long time if selinux.selinuxfs_exists(): yield selinux.selinux_current_policy_path()
#!/usr/bin/env python3 try: import warnings with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=PendingDeprecationWarning) import selinux if selinux.is_selinux_enabled(): print(selinux.selinux_binary_policy_path()) except ImportError: exit(0)