utils.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:lecm 作者: Spredzy 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号