SELinux权限被拒绝Python3.3 CentOS 6.5

时间:2015-02-19 02:46:59

标签: selinux

我在这个问题上遇到了困难。我试图通过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)

2 个答案:

答案 0 :(得分:0)

我也是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"

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

此致,Victor。

答案 1 :(得分:0)

如果第一个不工作尝试第二个问题,我有两种方式可以解决问题:

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

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

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

运行以下命令修复了问题:

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

第二个在此处显示here

干杯!