MOON
Server: Apache
System: Linux s5.yayogua.com.py 6.12.0-124.55.3.el10_1.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:54:02 EDT 2026 x86_64
User: sanbercountryclu (1012)
PHP: 8.2.33
Disabled: NONE
Upload Files
File: //lib64/python3.12/site-packages/setools/roletypesquery.py
# Copyright 2025, Christian Göttsche
#
# SPDX-License-Identifier: LGPL-2.1-only
#
from collections.abc import Iterable
import typing

from . import mixins, policyrep, query

__all__: typing.Final[tuple[str, ...]] = ("RoleTypesQuery",)


class RoleTypesQuery(mixins.MatchName, query.PolicyQuery):

    """
    Query SELinux policy roles.

    Parameter:
    policy            The policy to query.

    Keyword Parameters/Class attributes:
    name         The type name to match.
    name_regex   If true, regular expression matching
                 will be used on the type names.
    """

    def results(self) -> Iterable[policyrep.Role]:
        """Generator which yields all matching roles."""
        self.log.info(f"Generating role-types results from {self.policy}")
        self._match_name_debug(self.log)

        for r in self.policy.roles():
            for t in r.types():
                if self._match_name(t):
                    yield r
                    break