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()
评论列表
文章目录