Configuration of spamassassin on Fedora 21 with Postfix

I was unable to find any help anywhere on installing spamassassin on a modern Fedora system. All the advice out there is old and doesn't apply - so far as I found anyway. The official documentation does NOT pertain to Fedora — it's too generic and is missing important Fedora implementation details.

And, how it's done is not enough straight-forward that I know what to do! The most important missing link appears to be what I tell to Postfix on how to call spamassassin. However, it's also completely unclear where configuration options are to be defined.

There's a lot more that follows but MAYBE this all boils down to nobody bothering to give appropriate information on what the Postfix smtpd_milter entry should be. AND, the entry I've tried is based on the data found in '/usr/share/doc/spamass-milter-postfix' this file says the right value is unix:/run/spamass-milter/postfix/sock BUT while the directory exists, the socket entry is not there, and the error message cited below is returned.

...OK, the longer story:

I've installed these versions:

spamass-milter-0.4.0-1.fc21.x86_64
spamass-milter-postfix-0.4.0-1.fc21.noarch
spamassassin-3.4.0-13.fc21.x86_64

And again, this is Fedora 21. The installed Postfix is:

postfix-2.11.3-1.fc21.x86_64

When I run 'man spamassassin' it points me to /var/lib/spammassassin/3.004000, which contains 'updates_spamassassin_org.cf and a subdirectory of the same name (minus the .cf) which in turn contains a large collection (65) of .cf files. The man page also points me to /usr/share/spamassassin which in turn contains a large collection (63) of similarly named .cf files which aren't quite identical.

I sure hope I don't have to learn everything about all of these to get spamassassin working! Thankfully - but insufficiently - the man page ALSO points me to /etc/mail/spamassassin which contains, among other things, a file called local.cf. In there I found a link to a page on how to install and integrate spamassassin with postfix - here (), but that advice wasn't sufficient AND appeared to not be so clueful. For example, among the first things it suggests is to create a group and user account called "spamfilter" when, of course, the stock yum install already created the account sa-milt, whose entry appears to be the right one:

sa-milt:x:982:477:SpamAssassin Milter:/var/lib/spamass-milter:/sbin/nologin 

I imagine that there needs to be an entry made in Postfix's main.cf to create or add an entry called smtpd_milters to include whatever link is needed to tell Postfix how to call spamassassin. PRESENTLY I have an entry for openDKIM:

# This is for openDKIM - missing are clamav and spamassassin:
smtpd_milters = inet:localhost:8891

So, it seems to me to be an error to create these user accounts. Also if these accounts ARE needed, why didn't the installation scripts already create the user and group? Additionally, it also talks about using "service" to start spamassassin, BUT, as any competent Fedora 21 System Administrator knows, you don't use "service", you use systemctl!

...Ignoring that...

The service DOES start - and stay up - using:

systemctl start spamassassin

BUT, it doesn't work.

In particular, it seems obvious to me there needs to have a hook into postfix, but it's also obvious that the non-Fedora 21 strategy of doing that fails. We are directed to update Postfix's main.cf smtpd_milters entry - here's what they suggest:

# First entry is for openDKIM 
smtpd_milters = inet:localhost:8891, unix:/run/spamass-milter/postfix/sock

The problem is, though, that this doesn't work. We get this in the log file:

postfix/smtpd[18151]: warning: connect to Milter service unix:/run/spamass-milter/postfix/sock: No such file or directory

Yet, I can't seem to find the CORRECT entry for smtpd_milters for this version combination!

CLEARLY there should be installation directions somewhere, but NONE of what I've found pertains to these versions. Please either tell me how this should be done or point me to where I can find a competent write-up that DOES apply! IN PARTICULAR, what's the appropriate smtpd_milters entry OR, how do I create a configuration combination (smtpd_milters / spamassassin configuration) that works?


Solution 1:

You need to start spamass service as well.

systemctl start spamass-milter

And verified it working by

systemctl status spamass-milter

and

netstat -an | grep spamass-milter

By default, spamassassin only shipped with spamd and spamc binary. Do daemon included in the package. That's why you need use integrator like bash script, amavisd or spamass-milter (like this case)

Solution 2:

It turns out that after much gnashing of teeth, I noticed that there's a package I had installed that NOBODY had referenced so far as I had ever seen. It's called spamass-milter-root.

So, after having checked EVERYTHING I could think of, I figured, why not? ... ("#" is the system root account's CLI prompt.)

# systemctl enable spamass-milter-root.service
Created symlink from /etc/systemd/system/multi-user.target.wants/spamass-milter-root.service to /usr/lib/systemd/system/spamass-milter-root.service.
# systemctl status spamass-milter-root.service  -;
● spamass-milter-root.service - Mail filter for SpamAssassin
   Loaded: loaded (/usr/lib/systemd/system/spamass-milter-root.service; disabled)
   Active: active (running) since Fri 2015-04-17 15:53:41 PDT; 1min 3s ago
  Process: 2353 ExecStartPre=/bin/chown -R root /run/spamass-milter (code=exited, status=0/SUCCESS)
 Main PID: 2356 (spamass-milter)
   CGroup: /system.slice/spamass-milter-root.service
           ├─2356 /usr/sbin/spamass-milter -g postfix -p /run/spamass-milter/...
           └─2370 /usr/bin/spamc

Apr 17 15:53:41 ms1 spamass-milter[2356]: spamass-milter 0.4.0 starting
Apr 17 15:54:00 ms1 spamass-milter[2356]: Could not retrieve sendmail mac...s

And, as I had a tail -f /var/log/maillog up in a window, I was shocked when SUDDENLY (!!) it all just started to work with hundreds of mails being processed by spamd before my very eyes! YAY!

Now there are other concerns, such as, what effect the analysis of these messages are having....

Just for clarity, here are the two commands that solved the problem... Keep in mind, this is with all the other configuration work done:

# systemctl enable spamass-milter-root.service
# systemctl start spamass-milter-root.service

Done.