在强制模式下,我在RHEL6上使用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设置工作,并强制设置失败。
在postfix 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的目的,但是我还没有find任何似乎在“我的水平”上的教程,(简短而翔实):-)所以在SElinux上我仍然是n00b。 非常愿意学习。
禁用SElinux不是我学习的方式。
问题是audit2allow – audit2allow postfixMine.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 };
我添加了write类tcp_socket到这个:
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
现在终于起作用了!