Skip to content

Commit

Permalink
Drop no longer needed is_selinux_supported() (#3191)
Browse files Browse the repository at this point in the history
Guest `has_selinux` fact should be used instead, now when we have guest
facts.
  • Loading branch information
happz committed Sep 17, 2024
1 parent 97374ce commit bf8da4a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
7 changes: 5 additions & 2 deletions tmt/steps/provision/podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,13 @@ def push(
if not self.is_ready:
return

self.debug("Update selinux context of the run workdir.", level=3)
assert self.parent.plan.my_run is not None # narrow type
assert self.parent.plan.workdir is not None # narrow type

# Relabel workdir to container_file_t if SELinux supported
if tmt.utils.is_selinux_supported():
self.debug("Update selinux context of the run workdir.", level=3)

if self.parent.plan.my_run.runner.facts.has_selinux:
self._run_guest_command(Command(
"chcon", "--recursive", "--type=container_file_t", self.parent.plan.workdir
), shell=False, silent=True)
Expand Down
11 changes: 0 additions & 11 deletions tmt/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5832,17 +5832,6 @@ def field(
)


@functools.cache
def is_selinux_supported() -> bool:
"""
Returns ``true`` if SELinux filesystem is supported by the kernel, ``false`` otherwise.
For detection ``/proc/filesystems`` is used, see ``man 5 filesystems`` for details.
"""
with open('/proc/filesystems') as file:
return any('selinuxfs' in line for line in file)


def locate_key_origin(node: fmf.Tree, key: str) -> Optional[fmf.Tree]:
"""
Find an fmf node where the given key is defined.
Expand Down

0 comments on commit bf8da4a

Please sign in to comment.