【问题标题】:SELinux Permission Denied Python3.3 CentOS 6.5SELinux Permission Denied Python3.3 CentOS 6.5
【发布时间】:2015-02-19 02:46:59
【问题描述】:

我在这方面遇到了困难。我正在尝试通过 Apache 获取我的 GIT 存储库,但我遇到了似乎与 SELinux 相关的错误。我是 SELinux 的新手。我需要帮助破译审计日志中的输出。我看到了将 SELinux 设置为允许模式以捕获错误然后通过命令运行它以为此操作构建 SELinux 配置文件的建议。我需要帮助从输出构建命令。我的 Apache 服务器正在调用 python CGI 脚本。这是审计日志输出:

    type=AVC msg=audit(1424300724.345:67): avc:  denied  { execute } for  pid=2306 comm="python3.3" path=2F746D702F666669316F59336968202864656C6574656429 dev=dm-0 ino=266176 scontext=unconfined_u:system_r:httpd_sys_script_t:s0 tcontext=unconfined_u:object_r:httpd_sys_rw_content_t:s0 tclass=file
type=SYSCALL msg=audit(1424300724.345:67): arch=c000003e syscall=9 success=yes exit=140223631540224 a0=0 a1=1000 a2=5 a3=1 items=0 ppid=2303 pid=2306 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=1 comm="python3.3" exe="/usr/local/bin/python3.3" subj=unconfined_u:system_r:httpd_sys_script_t:s0 key=(null)

【问题讨论】:

    标签: selinux


    【解决方案1】:

    我也是 SELinux 的新手,但是我了解到对于 CGI 脚本,您的文件需要将其 TYPE 属性设置为 httpd_sys_script_exec_t ~ see this link

    您可以使用 semanage fcontext 命令将 CGI 脚本设置为所需的类型。 semanage link

    我相信你会这样运行:

    semanage fcontext -a -t httpd_sys_script_exec_t  "file.py"
    

    请查看手册以确认/澄清上述任何一项。

    问候,维克多。

    【讨论】:

      【解决方案2】:

      如果第一种不起作用,我知道有两种方法可以解决这个问题:尝试第二种:

      第一个:你需要查看Selinux日志打印所有与python相关的错误:

      sudo cat /var/log/audit/audit.log | grep python | grep denied
      

      我们将使用audit2allow 来解决此问题。如果没有,则需要通过yum 安装policycoreutils-python

      运行以下命令解决了这个问题:

      sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mypython
      sudo semodule -i mynginx.pp
      

      第二个在这里展示here

      干杯!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-07-30
        • 2021-08-31
        • 2013-01-25
        • 2012-01-29
        • 2015-03-29
        • 1970-01-01
        • 2011-08-30
        • 2018-07-21
        相关资源
        最近更新 更多