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

Replace libselinux restorecon API with CLI #4926

Merged
merged 1 commit into from
Jan 15, 2025
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
28 changes: 23 additions & 5 deletions base/server/python/pki/server/deployment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5188,11 +5188,29 @@ def store_manifest(self):
self.instance.copy(manifest_file, manifest_archive, force=True)

def restore_selinux_contexts(self):

selinux.restorecon(self.instance.base_dir, True)
selinux.restorecon(config.PKI_DEPLOYMENT_LOG_ROOT, True)
selinux.restorecon(self.instance.actual_logs_dir, True)
selinux.restorecon(self.instance.actual_conf_dir, True)
# The restocon API is not working in RHEL
# (see https://issues.redhat.com/browse/RHEL-73348).
#
#selinux.restorecon(self.instance.base_dir, True)
#selinux.restorecon(config.PKI_DEPLOYMENT_LOG_ROOT, True)
#selinux.restorecon(self.instance.actual_logs_dir, True)
#selinux.restorecon(self.instance.actual_conf_dir, True)
folders = [
self.instance.base_dir,
config.PKI_DEPLOYMENT_LOG_ROOT,
self.instance.actual_logs_dir,
self.instance.actual_conf_dir
]
for folder in folders:
cmd = [
'/usr/sbin/restorecon',
'-R'
]
if logger.isEnabledFor(logging.DEBUG):
cmd.append('-v')
cmd.append(folder)
logger.debug('Command: %s', ' '.join(cmd))
subprocess.run(cmd, check=True)

def selinux_context_exists(self, records, context_value):
'''
Expand Down
Loading