Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to support python 3.9 (RHEL9) #820

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions support/validate-appconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ class ContextValidator:

"""Validate contexts using security_check_context or chkcon"""

def __init__(self, /, policy_path: str | None = None, *,
chkcon_path: str | None = None) -> None:
def __init__(self, /, policy_path: typing.Optional[str]= None, *,
chkcon_path: typing.Optional[str] = None) -> None:

self.log = logging.getLogger(__name__).getChild(self.__class__.__name__)
self.selinux_enabled = libselinux.is_selinux_enabled() == 1
self.policy_path = policy_path
self.chkcon_path: Path | str | None = self._find_chkcon(chkcon_path)

self.chkcon_path: typing.Optional[Path, str, None] = self._find_chkcon(chkcon_path)
try:
self.policy = setools.SELinuxPolicy(policy_path) \
if self.selinux_enabled or policy_path else None
Expand All @@ -75,14 +74,18 @@ def __init__(self, /, policy_path: str | None = None, *,
self.dta = None
self.rbacrq = None
self.log.warning(f"SETools not available. {sys.path=}")
except AttributeError:
self.dta = None
self.rbacrq = None
self.log.warning(f"Old SETools Available - partial analysis only. {sys.path=}")

self.log.debug(f"{self.__class__.__name__}: "
f"{self.selinux_enabled=}, "
f"{self.policy_path=}, "
f"{self.policy=}, "
f"{self.chkcon_path=}")

def _find_chkcon(self, /, path: Path | str | None) -> Path | str | None:
def _find_chkcon(self, /, path: typing.Union[Path, str, None]) -> typing.Union[Path, str, None]:
if path:
self.log.debug(f"Checking access on provided chkcon path {path}")
if os.access(path, os.X_OK):
Expand Down Expand Up @@ -588,8 +591,8 @@ def validate_default_contexts(validator: ContextValidator, default_contexts: Pat


def validate_appconfig_files(conf_dir: str, /, *,
policy_path: str | None = None,
chkcon_path: str | None = None,
policy_path: typing.Optional[str] = None,
chkcon_path: typing.Optional[str] = None,
lxc: bool = True,
sepgsql: bool = True,
virt: bool = True,
Expand Down
Loading