I'm trying to follow this tutorial


But Spamassassin is giving an error

[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  ]

Even though it has permissions!

[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
# sudo -u spam touch /usr/local/spamassassin/spamfilter.log

Here is sysconfig file

[root@ip-172-99-99-99 ~]# cat /etc/sysconfig/spamassassin
# Options to spamd
SPAMDOPTIONS="-d -c -m5 --username ${SUSER} -H ${SAHOME} -s ${SAHOME}/spamfilter.log"

I have SELinux enabled.

# sestatus
SELinux status:                 enabled

# ls -Z /usr/local/spamassassin/
-rw-r--r--. spam spam unconfined_u:object_r:usr_t:s0   spamfilter.log

I tried to change the context of the directory, but it failed, even though I'm 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 release 6.8 (Final)



chcon -Rv --type=spamc_home_t /usr/local/spamassassin
semanage fcontext -a -t spamc_home_t "/usr/local/spamassassin(/.*)?"

1) Permissions throughout directory tree
2) Can`t remember it exactly, but daemon may want to recreate file, so it will need execute permission on it

  • Added sudo test. Execute to re-create? That is just a delete and write. – Chloe Jan 4 '17 at 22:03
  • So logger starts on different permissions and can't access directory with spamfilter.log – Sarenka Jan 4 '17 at 22:24
  • spamd starts as spam user. See SUSER=spam and --username ${SUSER}. – Chloe Jan 4 '17 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.