AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 422159
Accepted
Mike Pennington
Mike Pennington
Asked: 2012-08-29 12:25:25 +0800 CST2012-08-29 12:25:25 +0800 CST 2012-08-29 12:25:25 +0800 CST

WSGI 无法访问文件,但权限正确

  • 772

我正在调试MoinMoinCentOS 上抛出权限错误的问题,但我无法追踪有问题的文件/目录在哪里。

我strace -vp <pid>在 apache 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 已经在运行,我open()在称为7;的文件上看不到相应的内容。因此我看到了权限问题,但我仍然不知道哪个文件有问题。

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

编辑 1:

在@lain 的指导下,我跑了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]#

我看到这是一个 FIFO 管道,但这对我的系统配置意味着什么?如何追踪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/

我在我的 wiki http 配置中使用它:

<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>
linux
  • 3 3 个回答
  • 1305 Views

3 个回答

  • Voted
  1. user9517
    2012-08-29T12:36:33+08:002012-08-29T12:36:33+08:00

    查看/proc/<PID>/fd其中应该列出所有PID已打开的打开文件。


    在我的 CentOS 系统上 fd 7 是

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

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

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

    您可以使用

    lsof | grep 266474069
    

    获取有关管道的信息。

    • 5
  2. PythonLearner
    2012-08-29T12:40:36+08:002012-08-29T12:40:36+08:00

    查看我的小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]

    • 3
  3. Best Answer
    Mike Pennington
    2012-09-14T11:18:21+08:002012-09-14T11:18:21+08:00

    问题是我SELINUX=enforcing在/etc/selinux/config.

    我设置后SELINUX=permissive,SELINUXTYPE=targeted重启后wsgi可以正确访问所有文件。

    • 0

相关问题

  • Linux 主机到主机迁移

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 如何在 Linux 下监控每个进程的网络 I/O 使用情况?

  • 在 RHEL4 上修改 CUPS 中的现有打印机设置

  • 为本地网络中的名称解析添加自定义 dns 条目

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve