我正在尝试按照本教程操作
但 Spamassassin 给出了错误
[root@ip-172-99-99-99 ~]# service spamassassin restart
Stopping spamd: [ OK ]
Starting spamd: Jan 4 21:17:10.569 [22463] warn: logger: failed to open file /usr/local/spamassassin/spamfilter.log: Permission denied
Jan 4 21:17:10.587 [22463] warn: logger: failed to add file method: logger: file initialization failed
[ OK ]
即使它有权限!
[root@ip-172-99-99-99 ~]# ls -ld /usr/local/spamassassin /usr/local/spamassassin/*
drwx------. 2 spam spam 4096 Jan 3 20:02 /usr/local/spamassassin
-rw-r--r--. 1 spam spam 0 Jan 3 20:02 /usr/local/spamassassin/spamfilter.log
# sudo -u spam ls /usr/local/spamassassin/spamfilter.log
/usr/local/spamassassin/spamfilter.log
# sudo -u spam touch /usr/local/spamassassin/spamfilter.log
这是 sysconfig 文件
[root@ip-172-99-99-99 ~]# cat /etc/sysconfig/spamassassin
# Options to spamd
SAHOME=/usr/local/spamassassin
SPID_DIR=/var/run/spamassassin
SUSER=spam
SPAMDOPTIONS="-d -c -m5 --username ${SUSER} -H ${SAHOME} -s ${SAHOME}/spamfilter.log"
我已启用 SELinux。
# sestatus
SELinux status: enabled
# ls -Z /usr/local/spamassassin/
-rw-r--r--. spam spam unconfined_u:object_r:usr_t:s0 spamfilter.log
我尝试改变目录的上下文,但是失败了,尽管我是 root 身份。
# grep spamd_t /var/log/audit/audit.log
type=AVC msg=audit(1483587389.449:354941): avc: denied { append } for pid=31588 comm="spamd" name="spamfilter.log" dev=xvde ino=24109 scontext=unconfined_u:system_r:spamd_t:s0 tcontext=unconfined_u:object_r:usr_t:s0 tclass=file
type=SYSCALL msg=audit(1483587389.449:354941): arch=c000003e syscall=2 success=no exit=-13 a0=3463960 a1=441 a2=1b6 a3=7ff745c00d50 items=0 ppid=31587 pid=31588 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts4 ses=4038 comm="spamd" exe="/usr/bin/perl" subj=unconfined_u:system_r:spamd_t:s0 key=(null)
# chcon -v --type=spamd_t /usr/local/spamassassin
changing security context of `/usr/local/spamassassin'
chcon: failed to change context of `/usr/local/spamassassin' to `system_u:object_r:spamd_t:s0': Permission denied
# sudo chcon -v --type=spamd_t /usr/local/spamassassin
changing security context of `/usr/local/spamassassin'
chcon: failed to change context of `/usr/local/spamassassin' to `system_u:object_r:spamd_t:s0': Permission denied
CentOS 版本 6.8(最终版)
答案1
https://wiki.centos.org/HowTos/SELinux#head-0f6390ddacfab39ee973ed8018a32212c2a02199
chcon -Rv --type=spamc_home_t /usr/local/spamassassin
semanage fcontext -a -t spamc_home_t "/usr/local/spamassassin(/.*)?"
答案2
检查:
1)整个目录树的权限
2)记不清了,但守护进程可能想要重新创建文件,因此需要对该文件有执行权限