2

I'm trying to follow this tutorial

https://www.rosehosting.com/blog/how-to-install-and-integrate-spamassassin-with-postfix-on-a-centos-6-vps/

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
/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
SAHOME=/usr/local/spamassassin
SPID_DIR=/var/run/spamassassin
SUSER=spam
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)

Chloe
  • 1,164
  • 4
  • 19
  • 35

2 Answers2

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(/.*)?"
Chloe
  • 1,164
  • 4
  • 19
  • 35
0

Check:
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

Sarenka
  • 21
  • 3