Skip to content
Open
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
34 changes: 16 additions & 18 deletions lecm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import copy
import logging
import os
import platform
import subprocess

LOG = logging.getLogger(__name__)
Expand All @@ -46,23 +45,22 @@ def filter_certificates(items, certificates):

def enforce_selinux_context(output_directory):

if platform.dist()[0] in ['fedora', 'centos', 'redhat']:
if os.path.exists('/sbin/semanage'):
FNULL = open(os.devnull, 'w')

# Set new selinux so it is persistent over reboot
command = 'semanage fcontext -a -t cert_t %s(/.*?)' % (
output_directory
)
p = subprocess.Popen(command.split(), stdout=FNULL,
stderr=subprocess.STDOUT)
p.wait()

# Ensure file have the right context applied
command = 'restorecon -Rv %s' % output_directory
p = subprocess.Popen(command.split(), stdout=FNULL,
stderr=subprocess.STDOUT)
p.wait()
if os.path.exists('/sbin/semanage'):
FNULL = open(os.devnull, 'w')

# Set new selinux so it is persistent over reboot
command = 'semanage fcontext -a -t cert_t %s(/.*?)' % (
output_directory
)
p = subprocess.Popen(command.split(), stdout=FNULL,
stderr=subprocess.STDOUT)
p.wait()

# Ensure file have the right context applied
command = 'restorecon -Rv %s' % output_directory
p = subprocess.Popen(command.split(), stdout=FNULL,
stderr=subprocess.STDOUT)
p.wait()


def reload_service(service_name, service_provider):
Expand Down