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
    • 最新
    • 标签
主页 / computer / 问题 / 1470927
Accepted
cfiske
cfiske
Asked: 2019-08-14 10:56:46 +0800 CST2019-08-14 10:56:46 +0800 CST 2019-08-14 10:56:46 +0800 CST

SELinux 阻止 procmail 执行 dspam 但没有 AVC 消息

  • 772

我有一个 CentOS 7 系统,我在其中使用 postfix 作为 MTA。某些用户.forward在他们的主目录中使用 procmail via:

# cat .forward
"|exec /usr/bin/procmail -f- || exit 75"

在这种情况下,我很难弄清楚为什么 SELinux 不允许 procmail 从以下位置执行 dspam .procmailrc:

:0fw: dspam.lock
| /usr/bin/dspam --client --stdout --deliver=spam,innocent

在 procmail 日志中,我得到:

procmail: Locking "dspam.lock"
procmail: Executing "/usr/bin/dspam,--client,--stdout,--deliver=spam,innocent"
/bin/sh: /usr/bin/dspam: Permission denied
procmail: Program failure (126) of "/usr/bin/dspam"
procmail: Rescue of unfiltered data succeeded
procmail: Unlocking "dspam.lock"

但是,如果我将 SELinux 设置为宽容模式,它就可以正常工作。

问题是它没有记录任何关于被拒绝内容的 AVC 消息。当我第一次设置时,我发现了一些差距audit2why并ausearch修复了它们。现在我什么也得不到,即使它显然是 SELinux 阻止它工作。

编辑:这是 dspam 二进制文件:

# ls -lZ /usr/bin/dspam
-r-x--s--x. dspam mail system_u:object_r:dspam_exec_t:s0 /usr/bin/dspam
selinux procmail
  • 2 2 个回答
  • 128 Views

2 个回答

  • Voted
  1. Best Answer
    Chris Bennett
    2019-09-12T20:44:36+08:002019-09-12T20:44:36+08:00

    我有一个非常相似的问题。在我的例子中,selinux 悄悄地阻止了我的 .procmailbin 文件夹中的代码执行(我已经将 .procmailbin 的默认上下文设置为 procmail_exec_t)。

    我还没有完全解决这个问题,但我相信答案的路径是指示 selinux 报告所有拒绝,默认情况下它不会这样做。

    要启用所有拒绝的完整报告,请使用以下命令:

    semodule --disable_dontaudit --build
    

    查看 audit.log 并酌情使用 sealert 来确定发生了什么。

    然后在完成使用后恢复正常:

    semodule --build
    

    祝你好运!就我而言,我正处于 sealert 阶段,向我展示了之前未出现过的信息:

    SELinux is preventing sh from search access on the directory /home/chris/.procmailbin.
    
    *****  Plugin catchall (100. confidence) suggests   **************************
    
    If you believe that sh should be allowed search access on the .procmailbin directory by default.
    Then you should report this as a bug.
    You can generate a local policy module to allow this access.
    Do
    allow this access for now by executing:
    # ausearch -c 'sh' --raw | audit2allow -M my-sh
    # semodule -X 300 -i my-sh.pp
    

    ...但我仍然需要审查这是否是实际问题以及最佳解决方案是什么。

    更新:所以,事实证明这为我解决了这个问题。

    以下是我构建的自定义模块的内容:

    # more procmailbin-sh-search.te
    
    module my-sh 1.0;
    
    require {
            type dmesg_t;
            type procmail_t;
            type procmail_exec_t;
            type abrt_t;
            class dir search;
            class process noatsecure;
    }
    
    #============= abrt_t ==============
    allow abrt_t dmesg_t:process noatsecure;
    
    #============= procmail_t ==============
    allow procmail_t procmail_exec_t:dir search;
    

    在我看来,这应该是默认行为,所以我想我会看看是否可以找出向谁报告此“错误”的人。

    • 0
  2. cfiske
    2019-09-27T22:10:09+08:002019-09-27T22:10:09+08:00

    因此,在查看了 Chris Bennett 的回答后,我使用semodule --disable_dontaudit了并且能够弄清楚我需要什么。这是我最终使 postfix+procmail+dspam 工作的结果:

    require {
        type dspam_rw_content_t;
        type dspam_t;
        type dspam_exec_t;
        type procmail_t;
        class dir { open read write getattr add_name search };
        class file { append getattr lock open read write setgid };
        class unix_stream_socket connectto;
    }
    
    #============= dspam_t ==============
    allow dspam_t dspam_rw_content_t:dir { open read write getattr add_name search };
    allow dspam_t dspam_rw_content_t:file { append getattr lock open write };
    
    #============= procmail_t ==============
    allow procmail_t dspam_exec_t:file { open read setgid };
    allow procmail_t dspam_t:unix_stream_socket connectto;
    
    • 0

相关问题

  • 如何在 SELinux 中授予“搜索”权限

Sidebar

Stats

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

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    Windows 10 服务称为 AarSvc_70f961。它是什么,我该如何禁用它?

    • 2 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Marko Smith

    ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1056)

    • 4 个回答
  • Marko Smith

    我如何知道 Windows 安装在哪个驱动器上?

    • 6 个回答
  • Martin Hope
    Albin 支持结束后如何激活 WindowsXP? 2019-11-18 03:50:17 +0800 CST
  • Martin Hope
    fixer1234 “HTTPS Everywhere”仍然相关吗? 2019-10-27 18:06:25 +0800 CST
  • Martin Hope
    Kagaratsch Windows 10 删除大量小文件的速度非常慢。有什么办法可以加快速度吗? 2019-09-23 06:05:43 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    Inter Sys Ctrl+C 和 Ctrl+V 是如何工作的? 2019-05-15 02:51:21 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve