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 / 问题 / 472321
Accepted
MattBianco
MattBianco
Asked: 2013-01-26 01:40:42 +0800 CST2013-01-26 01:40:42 +0800 CST 2013-01-26 01:40:42 +0800 CST

如何使用自定义 milter 强制执行 SElinux 和 postfix?

  • 772

我在 RHEL6 上有一个 IPv4 后缀设置,SElinux 处于强制模式。除非我离开强制模式,否则我所有合并 opendkim 的尝试都惨遭失败。

我在 SElinux 执行时遇到的错误:

Jan 25 09:57:25 <mail.warning> katniss postfix/cleanup[16571]: warning: cannot receive milters via service cleanup socket socket
Jan 25 09:57:25 <mail.crit> katniss postfix/cleanup[16571]: fatal: cleanup_milter_receive: milter receive failed
Jan 25 09:57:26 <mail.warning> katniss postfix/smtpd[16567]: warning: cannot send milters to service public/cleanup socket
Jan 25 09:57:26 <mail.warning> katniss postfix/master[16559]: warning: process /usr/libexec/postfix/cleanup pid 16571 exit status 1
Jan 25 09:57:26 <mail.warning> katniss postfix/master[16559]: warning: /usr/libexec/postfix/cleanup: bad command startup -- throttling

我最近做了什么:

setenforce permissive

(发送邮件有效)

setenforce enforcing

(发送邮件失败并cleanup出现上述错误)

egrep -e 'postfix|opendkim|cleanup' /var/log/audit/audit.log | audit2allow -m postfixMine > postfixMine.te
checkmodule -M -m -o postfixMine.mod postfixMine.te 
semodule_package -m postfixMine.mod -o postfixMine.pp
semodule -i postfixMine.pp

(发送邮件仍然失败,出现与cleanup上面相同的错误)

因此,在允许的 SElinux 设置下,一切都按预期工作,而在强制设置下失败。

在后缀中main.cf:

smtpd_milters           = inet:127.0.0.1:8891
non_smtpd_milters       = $smtpd_milters
milter_default_action   = accept
milter_protocol         = 2

一些信息:

# netstat -napl | grep 8891
tcp        0      0 127.0.0.1:8891              0.0.0.0:*                   LISTEN      16464/opendkim      

# ps -ef|grep opendkim
opendkim 16463     1  0 09:56 ?        00:00:00 /usr/local/sbin/opendkim -x /etc/opendkim.conf -P /var/run/opendkim/opendkim.pid
opendkim 16464 16463  0 09:56 ?        00:00:00 /usr/local/sbin/opendkim -x /etc/opendkim.conf -P /var/run/opendkim/opendkim.pid

# ls -lZ /usr/libexec/postfix/cleanup
-rwxr-xr-x. root root system_u:object_r:postfix_cleanup_exec_t:SystemLow /usr/libexec/postfix/cleanup

在我开始脱掉头发之前,有人能给我指出正确的方向吗?一定有一些非常简单的东西我忽略了。

我知道 SElinux 的用途,但我还没有找到任何似乎达到“我的水平”的教程(简短且内容丰富):-) 所以说到 SElinux,我仍然是一个 n00b。非常愿意学习。

禁用 SElinux 不是我学习的方式。

postfix
  • 1 1 个回答
  • 2476 Views

1 个回答

  • Voted
  1. Best Answer
    MattBianco
    2013-01-26T03:44:24+08:002013-01-26T03:44:24+08:00

    问题是audit2allow-generatedpostfixMine.te变成了:

    module postfixMattias 1.0;
    
    require {
        type postfix_smtpd_t;
        type postfix_cleanup_t;
        class tcp_socket { getopt getattr };
    }
    
    #============= postfix_cleanup_t ==============
    #!!!! This avc is allowed in the current policy
    
    allow postfix_cleanup_t postfix_smtpd_t:tcp_socket { getopt getattr };
    

    我将tcp_socket 添加到类中read:write

    module postfixMine 1.0;
    
    require {
        type postfix_smtpd_t;
        type postfix_cleanup_t;
        class tcp_socket { getopt getattr read write };
    }
    
    #============= postfix_cleanup_t ==============
    #!!!! This avc is allowed in the current policy
    
    allow postfix_cleanup_t postfix_smtpd_t:tcp_socket { getopt getattr read write };
    

    随后是这些命令以重新编译新策略:

    checkmodule -M -m -o postfixMine.mod postfixMine.te 
    semodule_package -m postfixMine.mod -o postfixMine.pp
    semodule -i postfixMine.pp
    

    现在它终于起作用了!

    • 1

相关问题

  • Postfix 在特定端口上接受邮件

  • 让 Postfix 以两种方式处理垃圾邮件

  • Postfix 或 exim:自动/程序化和转发电子邮件设置

  • 后缀电子邮件地址

  • 什么是最好的开源电子邮件解决方案包

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