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 / 问题 / 796974
Accepted
JDS
JDS
Asked: 2016-08-16 13:06:59 +0800 CST2016-08-16 13:06:59 +0800 CST 2016-08-16 13:06:59 +0800 CST

SELinux 拒绝访问创建文件,但比较所有 selinux 设置显示没有问题

  • 772

我有两个应该相同的 Centos 7 系统(数据除外)。

我在服务器 A 上有一个服务器进程,该进程被拒绝写入特定目录。拒绝显示为 SELinux 拒绝。

在服务器 B 上,不会拒绝同一服务对同一目录的写访问。

我比较了两台服务器之间的文件权限、目录权限、ACL 和 SELinux 上下文,它们看起来相同——除了 A 得到“拒绝”错误而 B 没有。

作为一种解决方法,我将 SELinux 设置为“Permissive”,现在 A 上的服务器进程可以写入目录。

在这一点上,我真的只是在寻找可以解决其他问题的想法;如果需要,我很乐意提供技术细节。我在 Linux 管理方面经验丰富,但在 SELinux 方面经验并不丰富,所以在这一点上我很难过。

编辑——技术细节

我遇到问题的服务是 IPA。但实际上,它是与 IPA 捆绑在一起的 Apache,不允许写入 memcached 目录。具体来说,用户“apache”被拒绝写访问“/var/run/ipa_memcached/”。

以下是我运行的命令,它们在服务器之间返回的结果完全相同(PID 除外)。(这些是以root身份运行的,所以以“$”开头的行是命令,下面是输出)

$ semanage fcontext -l | grep memc
/var/run/memcached(/.*)?                           all files          system_u:object_r:memcached_var_run_t:s0
/var/run/ipa_memcached(/.*)?                       all files          system_u:object_r:memcached_var_run_t:s0
/usr/bin/memcached                                 regular file       system_u:object_r:memcached_exec_t:s0
/etc/rc\.d/init\.d/memcached                       regular file       system_u:object_r:memcached_initrc_exec_t:s0

$ ls -ldZ /var/run/ipa_memcached/; ls -lZ /var/run/ipa_memcached/
drwx------. apache apache system_u:object_r:memcached_var_run_t:s0 /var/run/ipa_memcached/
srwx------. apache apache system_u:object_r:memcached_var_run_t:s0 ipa_memcached
-rw-r--r--. apache apache system_u:object_r:memcached_var_run_t:s0 ipa_memcached.pid

$ sudo -u apache id -Z
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

$ ps auxZ | grep http
system_u:system_r:httpd_t:s0    apache   12321  0.0  6.6 674224 124860 ?       Sl   19:07   0:06 (wsgi:ipa)      -DFOREGROUND
system_u:system_r:httpd_t:s0    apache   12322  0.0  1.3 324060 26040 ?        S    19:07   0:00 /usr/sbin/httpd -DFOREGROUND
system_u:system_r:httpd_t:s0    kdcproxy 12319  0.0  1.2 628032 23604 ?        Sl   19:07   0:00 (wsgi:kdcproxy) -DFOREGROUND
system_u:system_r:httpd_t:s0    kdcproxy 12320  0.0  1.2 628032 23604 ?        Sl   19:07   0:00 (wsgi:kdcproxy) -DFOREGROUND
system_u:system_r:httpd_t:s0    root     12314  0.0  1.3 298704 24652 ?        Ss   19:07   0:00 /usr/sbin/httpd -DFOREGROUND
system_u:system_r:httpd_t:s0    root     12318  0.0  0.5  53880 11096 ?        S    19:07   0:00 /usr/libexec/nss_pcache 4423694 off /etc/httpd/alias
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 root 17615 0.0  0.0 112648 972 pts/0 R+ 21:11   0:00 grep --color=auto http

$ find /var/run/ipa* | xargs getfacl
getfacl: Removing leading '/' from absolute path names
# file: var/run/ipa
# owner: root
# group: root
user::rwx
group::---
other::---

# file: var/run/ipa/services.list
# owner: root
# group: root
user::rw-
group::r--
other::r--

# file: var/run/ipa/renewal.lock
# owner: root
# group: root
user::rw-
group::---
other::---

# file: var/run/ipa_memcached
# owner: apache
# group: apache
user::rwx
group::---
other::---

# file: var/run/ipa_memcached/ipa_memcached.pid
# owner: apache
# group: apache
user::rw-
group::r--
other::r--

# file: var/run/ipa_memcached/ipa_memcached
# owner: apache
# group: apache
user::rwx
group::---
other::---

编辑发现问题

audit2why向我展示了真正导致我的问题的原因

grep jsilverman /var/log/audit/audit.log* | grep denied| audit2why
...
/var/log/audit/audit.log.1:type=AVC msg=audit(1471293346.098:440365): avc:  denied  { create } for  pid=13668 comm="httpd" name="krbcc_A_jsilverman" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:memcached_var_run_t:s0 tclass=file

Was caused by:
The boolean httpd_manage_ipa was set incorrectly.
Description:
Allow httpd to manage ipa

Allow access by executing:
# setsebool -P httpd_manage_ipa 1
... (and more, similar messages) ...

这导致比较 selinux 设置

服务器 A

$ getsebool  -a| grep httpd_manage_ipa
httpd_manage_ipa --> off 

服务器 B

$ getsebool  -a| grep httpd_manage
httpd_manage_ipa --> on

现在,这怎么可能发生?另外,如何从 B->A 克隆 ​​selinux 设置?

permissions access-control-list selinux
  • 1 1 个回答
  • 1341 Views

1 个回答

  • Voted
  1. Best Answer
    yetdot
    2016-08-16T14:22:47+08:002016-08-16T14:22:47+08:00

    无论如何都不是答案,但是您认为 audit2why 或 audit2allow 的输出(如果可用)是什么?他们是否指定了可能需要更新以允许访问的模块?

    • 1

相关问题

  • 如何在 Exchange 2007 中设置资源邮箱日历的忙/闲权限?

  • 共享文件夹中某些文件的访问被拒绝错误

  • Bash 脚本:要求脚本以 root 身份运行(或使用 sudo)

  • 如何授予用户安装 Windows 服务的能力?

  • 限制用户向电子邮件地址发送电子邮件

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