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 / 问题 / 740997
Accepted
Rovanion
Rovanion
Asked: 2015-12-06 10:13:02 +0800 CST2015-12-06 10:13:02 +0800 CST 2015-12-06 10:13:02 +0800 CST

具有 ACL 组读取权限的用户拒绝读取权限

  • 772

介绍

Web 应用程序的一个常见场景是它有两个通用文件夹。一种是由应用程序服务器执行的代码,例如 uwsgi,另一种是由 Web 服务器直接交付的静态内容,例如 nginx。

在 Debian 服务器上,Web 服务器的用户帐户是 www-data,而应用程序服务器通常每个应用程序都是唯一的。这意味着在代码文件中可以有如下的acl:

# file: code/main.py
# owner: user
# group: user
user::rwx
group::rwx
group:app-server:rwx
other::---

静态文件可以具有以下 ACL:

# file: static/bootstrap.css
# owner: user
# group: user
user::rwx
group::rwx
group:app-server:rwx
group:www-data:r--
other::---

实际问题

具有这些权限的文件怎么可能:

$ sudo getfacl /srv/domain/django/static_files/bootstrap/css/bootstrap.css
getfacl: Removing leading '/' from absolute path names
# file: srv/domain/django/static_files/bootstrap/css/bootstrap.css
# owner: user
# group: user
user::rwx
group::rwx
group:www-data:r--
group:app-server:rwx
group:user-organization:rwx
mask::rwx
other::---

www-data 不可读:

$ sudo -u www-data cat /srv/domain/django/static_files/bootstrap/css/bootstrap.css
cat: /srv/domain/django/static_files/bootstrap/css/bootstrap.css: Permission denied

当用户 www-data 明确是同名组的成员时:

$ id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data)

事实上,放弃所有控制权并允许任何人阅读对这种情况没有任何帮助:

$ sudo chmod 774 /srv/domain/django/static_files/bootstrap/css/bootstrap.css
$ sudo getfacl /srv/domain/django/static_files/bootstrap/css/bootstrap.css
getfacl: Removing leading '/' from absolute path names
# file: srv/domain/django/static_files/bootstrap/css/bootstrap.css
# owner: user
# group: user
user::rwx
group::rwx
group:www-data:r--
group:app-server:rwx
group:user-organization:rwx
mask::rwx
other::r--
$ cat /srv/domain/django/static_files/bootstrap/css/bootstrap.css
cat: /srv/domain/django/static_files/bootstrap/css/bootstrap.css: Permission denied

使用 chown 和 chgrp 将文件的所有权和组更改为 www-data 不会改变结果。我对 dmesg、messages 或 auth.log 没有任何兴趣。

所以有些事情正在发生,但我完全没有想法。

file-permissions
  • 1 1 个回答
  • 1322 Views

1 个回答

  • Voted
  1. Best Answer
    Rovanion
    2015-12-07T00:17:56+08:002015-12-07T00:17:56+08:00

    答案在于用户组必须对通向包含该文件的文件夹的每个文件夹具有列出或执行权限。

    换句话说,解决方案如下:

    $ sudo setfacl -m g:www-data:X /srv/domain
    $ sudo setfacl -m g:www-data:X /srv/domain/django
    $ sudo setfacl -R -m g:www-data:rX /srv/domain/django/static_files
    
    • 4

相关问题

  • 如何限制用户移动文件夹?

  • 将权限复制到 linux / unix 上的相同树

  • 启用 apache 在目录中打开/写入?

  • 在 /var/www 中处理 Apache 2 的用户 www-data 权限的最佳方法是什么?

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