コード例 #1
0
ファイル: __init__.py プロジェクト: SELinuxProject/selinux
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"))
コード例 #2
0
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"))
コード例 #3
0
ファイル: __init__.py プロジェクト: jbrindle/selinux
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"))
コード例 #4
0
    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)
コード例 #5
0
    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)
コード例 #6
0
    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()
コード例 #7
0
#!/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)