WSGI不能访问文件,但权限是正确的

我正在debuggingCentOS上的MoinMoin抛出一个权限错误的问题,但我无法追查有问题的文件/目录。

我在apache上运行strace -vp <pid> ; 当我遇到问题时,我看到:

 epoll_wait(10, {{EPOLLIN, {u32=3487534344, u64=140367313734920}}}, 2, 10000) = 1 accept4(6, {sa_family=AF_INET6, sin6_port=htons(52621), inet_pton (AF_INET6, "::ffff:105.193.30.91", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, [28], SOCK_CLOEXEC) = 11 ## Later on... read(7, 0x7fffa658ad7f, 1) = -1 EAGAIN (Resource temporarily unavailable) 

但是,由于apache已经在运行,所以在文件7上我看不到相应的open() 。 因此我看到权限问题,但我仍然不知道哪个文件是问题。

我知道我可以尝试捕获所有的文件打开时,我重新生成的Apache,但我希望有一种方法来映射文件7到一个真正的文件名…有没有办法做到这一点?

编辑1:

使用@lain的指导,我跑了lsof | grep 266474069 lsof | grep 266474069 ,但结果不清楚…

 [root@lnxlmf moin]# ls -la /proc/9707/fd/7 lr-x------. 1 root root 64 Aug 28 15:39 /proc/9707/fd/7 -> pipe:[266474069] [root@lnxlmf moin]# [root@lnxlmf moin]# lsof | grep 266474069 httpd 9703 root 7r FIFO 0,8 0t0 266474069 pipe httpd 9703 root 8w FIFO 0,8 0t0 266474069 pipe httpd 9705 apache 7r FIFO 0,8 0t0 266474069 pipe httpd 9705 apache 8w FIFO 0,8 0t0 266474069 pipe httpd 9706 apache 7r FIFO 0,8 0t0 266474069 pipe httpd 9706 apache 8w FIFO 0,8 0t0 266474069 pipe httpd 9707 apache 7r FIFO 0,8 0t0 266474069 pipe httpd 9707 apache 8w FIFO 0,8 0t0 266474069 pipe httpd 9733 apache 7r FIFO 0,8 0t0 266474069 pipe httpd 9733 apache 8w FIFO 0,8 0t0 266474069 pipe [root@lnxlmf moin]# 

我看到这是一个FIFOpipe道,但这对我的系统configuration意味着什么? 如何追踪EAGAIN问题的根本原因?

编辑2:

感谢@Alan Curry,运行strace -fp <pid_of_wsgi_proc>似乎让我有点进一步…

 [pid 9731] stat("/opt/moin/share/moin/wikiconfig.py", {st_mode=S_IFREG|0770, st_size=6463, ...}) = 0 [pid 9731] stat("/opt/moin/share/moin/data/pages", {st_mode=S_IFDIR|0770, st_size=4096, ...}) = 0 [pid 9731] access("/opt/moin/share/moin/data/pages", R_OK|W_OK|X_OK) = -1 EACCES (Permission denied) 

但是,apache和wsgi都是作为apache用户运行的。

 [root@lnxlmf moin]# ps auxw | grep -E "apache|wsgi" apache 10187 0.0 0.1 373488 5884 ? Sl 17:18 0:00 moin_http_wsgi apache 10188 0.0 0.1 373488 5884 ? Sl 17:18 0:00 moin_https_wsgi apache 10189 0.0 0.1 185096 5824 ? S 17:18 0:00 /usr/sbin/httpd root 10243 0.0 0.0 103240 848 pts/1 S+ 17:21 0:00 grep -E apache|wsgi [root@lnxlmf moin]# 

然而,当我运行以下命令并重新启动Apache,我仍然无法解决问题…

 [root@lnxlmf moin]# pwd /opt/moin/share/moin [root@lnxlmf moin]# chown -R apache:apache data/ [root@lnxlmf moin]# sudo chmod -R ug+rwx data/ [root@lnxlmf moin]# sudo chmod -R o-rwx data/ 

我在我的维基httpconfiguration中使用这个:

 <VirtualHost *:443> ServerName netwiki.foo.com DocumentRoot /opt/moin/share/moin WSGIScriptAlias / /opt/moin/share/moin/server/moin.wsgi WSGIDaemonProcess moin_https display-name=moin_https_wsgi \ user=apache group=apache \ processes=1 threads=10 maximum-requests=1000 umask=0007 WSGIProcessGroup moin_https WSGIApplicationGroup %{GLOBAL} # Generate with... # openssl req -new -x509 -days 365 -nodes -out netwiki.pem -keyout netwiki.key SSLEngine on SSLCertificateFile /etc/httpd/ssl/netwiki.pem SSLCertificateKeyFile /etc/httpd/ssl/netwiki.key </VirtualHost> 

看一下/proc/<PID>/fd ,它应该列出所有打开的PID文件。


在我的CentOS系统fd 7是

 lrwx------. 1 root root 64 Aug 28 22:01 7 -> socket:[1872522] 

然后我可以使用netstat -ane | grep 1872522 netstat -ane | grep 1872522得到

 tcp 0 0 :::443 :::* LISTEN 0 1872522 

您可以使用

 lsof | grep 266474069 

获取pipe道信息。

看着我的小VPS,我可以通过以下方式确定fd编号:

  ll /proc/17684/fd/ |colrm 1 46 0 -> /dev/null 1 -> /dev/null 10 -> /var/www/vhosts/censored.xenuser.org/statistics/logs/error_log 11 -> /var/www/vhosts/censored.de/statistics/logs/error_log 12 -> /var/www/vhosts/censored.org/statistics/logs/error_log 13 -> /var/www/vhosts/xenuser.org/statistics/logs/error_log 14 -> /var/log/apache2/access.log 

[等等,其中17684是我先前讨论的过程的PID]

问题是我有SELINUX=enforcing/etc/selinux/config SELINUX=enforcing

设置SELINUX=permissiveSELINUXTYPE=targeted ,并重新启动wsgi可以正确访问所有文件。