You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Linkcheck <sp...@linkcheck.co.uk> on 2019/11/07 15:25:57 UTC

Getting spamass-milter to work with postfix

I have run spamassassin as a postfix content filter (master.cf) for 
several years on Linux Mint (Ubuntu 16.04) but I now need to run 
spamass-milter instead. I have spent several hours trying to find the 
correct setup but those I've found are somewhat conflicting and I cannot 
determine which files I should modify and how. I would appreciate some 
help in setting up the milter.

Spamassassin version: 3.4.2
Postfix version: 3.1.0

I have the following spamassassin folders/files files with the contents 
shown:

/etc/spampd.conf
  (all is commented out)

/etc/default/spamassassin
   ENABLED=0
   OPTIONS="--create-prefs --maxchildren 5 -- helper-home-dir"

/etc/default/spamass-milter
   OPTIONS="-u spamass-milter -i 127.0.0.1"

/etc/default/spampd
   STARTSPAMPD=1
   PIDFILE=/var/run/spampd.pid
   LISTENHOST=127.0.0.1
   LISTENPORT=10025
   DESTHOST=127.0.0.1
   DESTPORT=10026
   CHILDREN=3
   USERID=spampd
   GRPID=spampd
   TAGALL=1
   AUTOWHITELIST=0
   LOCALONLY=1
   LOGINET=0
   ADDOPTS=""
(do I need to include the listen/dest values or does it not matter?)

(headers only given for the following three)
/etc/init.d/spamassassin
   PATH=/sbin:/bin:/usr/sbin:/usr/bin
   DAEMON=/usr/sbin/spamd
   NAME=spamd
   SNAME=spamassassin
   DESC="SpamAssassin Mail Filter Daemon"
   PIDFILE="/var/run/$NAME.pid"
   export TMPDIR=/tmp
   ENABLED=0
   OPTIONS=""
   NICE=
   . /lib/lsb/init-functions
   test -f /etc/default/spamassassin && . /etc/default/spamassassin
   DOPTIONS="-d --pidfile=$PIDFILE"
(I'm confused by the line: . /lib etc - is this valid? and see below also)

/etc/init.d/spamass-milter
   PATH=/sbin:/bin:/usr/sbin:/usr/bin
   NAME=spamass-milter
   DAEMON=/usr/sbin/spamass-milter
   SOCKET=/var/run/spamass/spamass.sock
   PIDFILE=/var/run/spamass/spamass.pid
   DESC="Sendmail milter plugin for SpamAssassin"
   DEFAULT=/etc/default/spamass-milter
   OPTIONS=""
   RUNAS="spamass-milter"
   CHUID=""
   SOCKETMODE="0600"
   SOCKETOWNER="postfix:postfix"

/etc/init.d/spampd
   PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
   DESC='spam checking proxy daemon'
   NAME='spampd'
   PROGRAM=/usr/sbin/spampd
   EXECUTABLE=/usr/bin/perl
   PIDFILE=/var/run/spampd.pid
   . /lib/lsb/init-functions
   USERID=spampd
   GRPID=spampd

/etc/spamassassin/
  (containing local.cf and local rules files)

/usr/share/spamassassin/
  (global rules files)

The last one I understand I do not need to worry about and in the one 
before local.cf has nothing relevant to the problem.

The only file that has a SOCK defined is /etc/init.d/spamass-milter. 
Should spamd also have a socket? Various online postings give 
conflicting advice.

My postfix master.cf has no enabled spamassassin content.

Postfix main.cf has:
   policy-spf_time_limit = 3600s
   milter_default_action = accept
   milter_protocol = 6
   smtpd_milters = unix:/var/run/opendkim/opendkim.sock, 
unix:/var/run/opendmarc/opendmarc.sock, 
unix:/var/run/spamass/spamass.sock, unix:/var/run/clamav/clamav-milter.ctl
   non_smtpd_milters = unix:/var/run/opendkim/opendkim.sock

The .pid files are as below; so far, no .sock files.

/var/run/spamassassin.pid (created during a postfix restart early today)
/var/run/spampd.pid (created during last m/c reboot)
/var/run/spamass/ (contains nothing)
   (permissions spamass-milter create/delete files, postfix ditto, 
others access only)

There is a folder at /var/spool/postfix/spamass/ with the same 
permissions as above but also empty.

All help appreciated!

Re: Getting spamass-milter to work with postfix

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
On 07.11.19 15:25, Linkcheck wrote:
>I have run spamassassin as a postfix content filter (master.cf) for 
>several years on Linux Mint (Ubuntu 16.04) but I now need to run 
>spamass-milter instead. I have spent several hours trying to find the 
>correct setup but those I've found are somewhat conflicting and I 
>cannot determine which files I should modify and how. I would 
>appreciate some help in setting up the milter.
>
>Spamassassin version: 3.4.2
>Postfix version: 3.1.0
>
>I have the following spamassassin folders/files files with the 
>contents shown:
>
>/etc/spampd.conf
>/etc/default/spampd
> (all is commented out)

spampd has nothing to do with spamass-milter.
you must enable spamd (spamassassin) when using spamass-milter.

>/etc/default/spamassassin
>  ENABLED=0
enable here^

>  OPTIONS="--create-prefs --maxchildren 5 -- helper-home-dir"


>/etc/default/spamass-milter
>  OPTIONS="-u spamass-milter -i 127.0.0.1"

>/etc/init.d/spamassassin
>  PATH=/sbin:/bin:/usr/sbin:/usr/bin
>  DAEMON=/usr/sbin/spamd
>  NAME=spamd
>  SNAME=spamassassin
>  DESC="SpamAssassin Mail Filter Daemon"
>  PIDFILE="/var/run/$NAME.pid"
>  export TMPDIR=/tmp
>  ENABLED=0
>  OPTIONS=""
>  NICE=
>  . /lib/lsb/init-functions
>  test -f /etc/default/spamassassin && . /etc/default/spamassassin
>  DOPTIONS="-d --pidfile=$PIDFILE"
>(I'm confused by the line: . /lib etc - is this valid? and see below also)
>
>/etc/init.d/spamass-milter
>  PATH=/sbin:/bin:/usr/sbin:/usr/bin
>  NAME=spamass-milter
>  DAEMON=/usr/sbin/spamass-milter
>  SOCKET=/var/run/spamass/spamass.sock
>  PIDFILE=/var/run/spamass/spamass.pid
>  DESC="Sendmail milter plugin for SpamAssassin"
>  DEFAULT=/etc/default/spamass-milter
>  OPTIONS=""
>  RUNAS="spamass-milter"
>  CHUID=""
>  SOCKETMODE="0600"
>  SOCKETOWNER="postfix:postfix"

>The only file that has a SOCK defined is /etc/init.d/spamass-milter. 
>Should spamd also have a socket? Various online postings give 
>conflicting advice.

spamd listens on localhost:783 by default and spamc (called by
spamass-milte) connects there. You can define unix domain socket by options
to either, but it's not neede.

>My postfix master.cf has no enabled spamassassin content.

not needed, spamass-milter uses it.

>Postfix main.cf has:
>  policy-spf_time_limit = 3600s
>  milter_default_action = accept
>  milter_protocol = 6
>  smtpd_milters = unix:/var/run/opendkim/opendkim.sock, 
>unix:/var/run/opendmarc/opendmarc.sock, 
>unix:/var/run/spamass/spamass.sock, 

this is afaik the default spamass-milter socket on debian/ubuntu.

>unix:/var/run/clamav/clamav-milter.ctl
>  non_smtpd_milters = unix:/var/run/opendkim/opendkim.sock

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Eagles may soar, but weasels don't get sucked into jet engines.

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
Thanks for that. I wasn't sure which config to add it to.

I now have the following in /etc/default/spamass-milter...

   OPTIONS="-u spamass-milter -i 127.0.0.1 -- -s 8000000"

... which works.

Re: Getting spamass-milter to work with postfix

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
On 28.11.19 16:40, Linkcheck wrote:
>Belated thans again to all who helped me with this problem. It has 
>been running reasonably well since my last posting. I now have only a 
>couple of minor problems left, one of which (I think) more suited to 
>the postfix forum.
>
>The other one is max-size. I had gradually uprated this to 8000000 in 
>the content filter .sh file, called via master.cf. I have tried 
>setting it in /etc/default/spamassassin as --max-size=8000000 (which 
>accepts it but ignores it) and in spamass-milter which does not accept 
>either the long or short version (which is expected from the docs).
>
>Where should I specify this and how, please?

spamass-milter calls spamc, which by default avoids mail bigger than 500KB.
you must provide extra spamc parameters in /etc/default/spamass-milter.

see man spamass-milter.


-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Windows 2000: 640 MB ought to be enough for anybody

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
Belated thans again to all who helped me with this problem. It has been 
running reasonably well since my last posting. I now have only a couple 
of minor problems left, one of which (I think) more suited to the 
postfix forum.

The other one is max-size. I had gradually uprated this to 8000000 in 
the content filter .sh file, called via master.cf. I have tried setting 
it in /etc/default/spamassassin as --max-size=8000000 (which accepts it 
but ignores it) and in spamass-milter which does not accept either the 
long or short version (which is expected from the docs).

Where should I specify this and how, please?


Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
Thank you for the explanation. Appreciated. :)

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
On 24/11/2019 18:23, Bill Cole wrote:
> setting "smtpd_delay_open_until_valid_rcpt = no" should make it available

Just tried that in main.cf, but no difference. No queue ID until after 
the connect line, just before the SPF tests. I wonder if the confMILTER 
error mitigates against it.

It also occurs to me that since a high proportion of connection attempts 
are spammy and are dropped almost immediately there could be a higher 
overhead?

Re: Getting spamass-milter to work with postfix

Posted by "@lbutlr" <kr...@kreme.com>.
On 24 Nov 2019, at 11:23, Bill Cole <sa...@billmail.scconsult.com> wrote:
> setting "smtpd_delay_open_until_valid_rcpt = no" should make it available. By default, postfix does not commit a file descriptor and queue ID to a message until it has an accepted recipient. Setting that option to "no" causes it to open the file and assign a queue ID at connect time, which also enhances the logging by postfix itsef, since every entry for a particular SMTP session has a common queue ID in it.

Well, that’s nifty!



-- 
Suddenly the animals look shiny and new


Re: Getting spamass-milter to work with postfix

Posted by Bill Cole <sa...@billmail.scconsult.com>.
On 24 Nov 2019, at 12:34, Matus UHLAR - fantomas wrote:

>> On 24/11/2019 15:57, Matus UHLAR - fantomas wrote:
>>> I have explained that this was caused by receiving mail for "admin" 
>>> thus
>>> spamass-milter provider username admin. Since the admin doesn't 
>>> exist
>>> locally (apparently alias or remote user), spamd falled back to 
>>> nobody.
>
> On 24.11.19 16:05, Linkcheck wrote:
>> Then how can I get it to use the correct user each time? Obviously 
>> there can be a lot of them.
>
> the recipient user is the correct on, his settings are used.  That's 
> why it
> is called per-user settings. This feature is built into sa-milter.
>
> However, looking at its docs, the '-u' user is only used when multiple
> recipients, otherwise the recipient's username is used.
>
> so, using this opion with spamass-milter is fine.  using this with 
> spamd
> disables per-user configs which may not be what ou want.
>
>> The solution to confMILTER is: ignore it. That particular feature was 
>> designed for sendmail and postfix cannot support it.
>
> according to sendmail docs, it's the queue ID. It's fine for logging.

Also: setting "smtpd_delay_open_until_valid_rcpt = no" should make it 
available. By default, postfix does not commit a file descriptor and 
queue ID to a message until it has an accepted recipient. Setting that 
option to "no" causes it to open the file and assign a queue ID at 
connect time, which also enhances the logging by postfix itsef, since 
every entry for a particular SMTP session has a common queue ID in it. 
There are minor performance & resource issues with that setting, so if 
you're handling more than a few score messages per second
you may want to test if you can use that setting without causing 
trouble.

-- 
Bill Cole
bill@scconsult.com or billcole@apache.org
(AKA @grumpybozo and many *@billmail.scconsult.com addresses)

Re: Getting spamass-milter to work with postfix

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
>On 24/11/2019 15:57, Matus UHLAR - fantomas wrote:
>>I have explained that this was caused by receiving mail for "admin" thus
>>spamass-milter provider username admin. Since the admin doesn't exist
>>locally (apparently alias or remote user), spamd falled back to nobody.

On 24.11.19 16:05, Linkcheck wrote:
>Then how can I get it to use the correct user each time? Obviously 
>there can be a lot of them.

the recipient user is the correct on, his settings are used.  That's why it
is called per-user settings. This feature is built into sa-milter.

However, looking at its docs, the '-u' user is only used when multiple
recipients, otherwise the recipient's username is used.

so, using this opion with spamass-milter is fine.  using this with spamd
disables per-user configs which may not be what ou want.

>The solution to confMILTER is: ignore it. That particular feature was 
>designed for sendmail and postfix cannot support it.

according to sendmail docs, it's the queue ID. It's fine for logging.

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
10 GOTO 10 : REM (C) Bill Gates 1998, All Rights Reserved!

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
On 24/11/2019 15:57, Matus UHLAR - fantomas wrote:
> I have explained that this was caused by receiving mail for "admin" thus
> spamass-milter provider username admin. Since the admin doesn't exist
> locally (apparently alias or remote user), spamd falled back to nobody.

Then how can I get it to use the correct user each time? Obviously there 
can be a lot of them.

The solution to confMILTER is: ignore it. That particular feature was 
designed for sendmail and postfix cannot support it.

Re: Getting spamass-milter to work with postfix

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
On 24.11.19 15:35, Linkcheck wrote:
>Almost there now. I found a reference online that said to add "-u 
>spamd" to the end of the OPTIONS line in /etc/defauls/spamassassin and 
>that removed the log entry...

this is the worst solution. It disables per-user config files.

>  spamd: still running as root: user not specified with -u, not found, 
>or set to root, falling back to nobody
>
>The posting also said that the line...
>  spamd: handle_user (getpwnam) unable to find user: 'admin'
>... was nothing to wory about.

I have explained that this was caused by receiving mail for "admin" thus
spamass-milter provider username admin. Since the admin doesn't exist
locally (apparently alias or remote user), spamd falled back to nobody.

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
42.7 percent of all statistics are made up on the spot.

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
Almost there now. I found a reference online that said to add "-u spamd" 
to the end of the OPTIONS line in /etc/defauls/spamassassin and that 
removed the log entry...

   spamd: still running as root: user not specified with -u, not found, 
or set to root, falling back to nobody

The posting also said that the line...
   spamd: handle_user (getpwnam) unable to find user: 'admin'
... was nothing to wory about.

Only thing left now, I think, is finding out where to change something 
to remove the startup message...
     Could not retrieve sendmail macro "i"! Please add it to 
confMILTER_MACROS_ENVFROM

Again, thanks for your help. :)

Re: Getting spamass-milter to work with postfix

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
>On 24/11/2019 14:47, Matus UHLAR - fantomas wrote:
>> then you have your problem fixed.

On 24.11.19 15:21, Linkcheck wrote:
>More or less. It works (although not sure what will happen on reboot - 
>will it auto-run spamass-milter and spamd?) but I am trying to clean 
>up the remaining log entries.

you can only find out by rebooting. And fix by configring spamass-milter
properly, not by manually changing owner/permissions of a socket that is
created dynamically.

>>comment any messages when you have removed them?
>
>Removed them from where? This list? I haven't done so. I was referring 
>to my messages which you quoted in a previous email...

I have quoted and then you have asked about them but removed them from the
mail so I couldn't comment...

however:

>> spamd: connection from ::1 [::1]:55492 to port 783, fd 5
>> spamd: handle_user (getpwnam) unable to find user: 'admin'
>> spamd: still running as root: user not specified with -u, not found, 
>> or set to root, falling back to nobody
>> spamd: processing message <message-id> for admin:65534
>
>I assume lines 1 and 4 are the usual "connecting" comment. I am 
>concerned about lines 2 and 3.
>
>I understand WHAT to do about line 3 but not WHERE. Whether that would 
>also remove line 2 I do not know.

They are warnings only. I have explained then in my former post.

good luck

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Linux - It's now safe to turn on your computer.
Linux - Teraz mozete pocitac bez obav zapnut.

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
On 24/11/2019 14:47, Matus UHLAR - fantomas wrote:
 > then you have your problem fixed.

More or less. It works (although not sure what will happen on reboot - 
will it auto-run spamass-milter and spamd?) but I am trying to clean up 
the remaining log entries.

> comment any messages when you have removed them?

Removed them from where? This list? I haven't done so. I was referring 
to my messages which you quoted in a previous email...

 > spamd: connection from ::1 [::1]:55492 to port 783, fd 5
 > spamd: handle_user (getpwnam) unable to find user: 'admin'
 > spamd: still running as root: user not specified with -u, not found, 
or set to root, falling back to nobody
 > spamd: processing message <message-id> for admin:65534

I assume lines 1 and 4 are the usual "connecting" comment. I am 
concerned about lines 2 and 3.

I understand WHAT to do about line 3 but not WHERE. Whether that would 
also remove line 2 I do not know.

I have been looking online for handle_user and found a number of 
postings in forums (including this one) which offer advice, but the ones 
I've found so far say "do this" but not where to do it, even in the 
official documentation.

Sorry if I appear to be ungrateful - I really do appreciate all the help 
you and others are giving me. I've been running linux and postfix for 
several years but am still easily confused by a few things.

Re: Getting spamass-milter to work with postfix

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
>On 24/11/2019 14:00, Matus UHLAR - fantomas wrote:
>>relative to the chroot value.

On 24.11.19 14:22, Linkcheck wrote:
>I repeat, no chroot involved! Otherwise, the two values are the same...

if you don't use chroot, then it's "/".

>main.cf
>  unix:/var/run/spamass/spamass.sock
>
>etc/default/spamass-milter
>  /var/run/spamass/spamass.sock

and in the beginning you complained about "No such file or directory" error.

>> set values of SOCKETOWNER and SOCKETMODE in default/spamass-milter
>
>That's already done anyway.
>
>> wants to process mail with settings of admin user
>
>Er, in what way?

spamd searchs for sser's ~/.spamassassin/user_prefs file and parses it.
If it can't find the user, it uses the default one.

the logs you have posted in previoud mail clearly said it didn't find ther
user and which user it used.

> Spamassassin is processing and reporting as expected 
>apart from the messages.

then you have your problem fixed.

> Are they warnings or errors? Or just 
>ignorable comments? (And if the latter, how can they be removed from 
>the logs - assuming they should be.)

iirc they were warnings, but why do you expect me or anyone to comment any
messages when you have removed them?

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
99 percent of lawyers give the rest a bad name.

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
On 24/11/2019 14:00, Matus UHLAR - fantomas wrote:
> relative to the chroot value.

I repeat, no chroot involved! Otherwise, the two values are the same...

main.cf
   unix:/var/run/spamass/spamass.sock

etc/default/spamass-milter
   /var/run/spamass/spamass.sock

 > set values of SOCKETOWNER and SOCKETMODE in default/spamass-milter

That's already done anyway.

 > wants to process mail with settings of admin user

Er, in what way? Spamassassin is processing and reporting as expected 
apart from the messages. Are they warnings or errors? Or just ignorable 
comments? (And if the latter, how can they be removed from the logs - 
assuming they should be.)


Re: Getting spamass-milter to work with postfix

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
On 24.11.19 12:33, Linkcheck wrote:
>As I understand it, altering those values in default/spamass-milter 
>should be sufficient? Those have been changed for several days now.

the SOCKET value in default/spamass-milter MUST agree with value in
smtpd_milters in main.cf relative to the chroot value.

default value of SOCKET in default/spamass-milter differs on different
systems, as does chroot setting.

You use a clone of Ubundy, which is clone of Debian - I don't know if your
system uses debian defaults.

>Following a lead from elsewhere I have altered the owner to 
>spamass-milter:postfix and the socket permissions follow it in the 
>file manager. However, the PID file is being created with 
>spamass-milter:nogroup and I cannot find where to change it - and does 
>it matter in this case?

no. However you should not change permission of a file.
Instead, you can set values of SOCKETOWNER and SOCKETMODE in
default/spamass-milter.

>In System Monitor (task manager) I'm seeing (currently) 2 spamd 
>processes, 2 spamd-child and a spamass-milter. Is that reasonable?

unrelated.

>I'm also seeing the following in the log for each email email...
>
>  spamd: connection from ::1 [::1]:55492 to port 783, fd 5
>  spamd: handle_user (getpwnam) unable to find user: 'admin'
>  spamd: still running as root: user not specified with -u, not found, 
>or set to root, falling back to nobody
>  spamd: processing message <message-id> for admin:65534š
>
>... where admin changes according to the target email address (eg 
>james, ebay etc) - I do not understand why line 2 is seeking user: 
>admin.

precisely because of that. spamass-milter found out the message is sent to
admin, so it wants to process mail with settings of admin user.

>line 3 running as root - according to default/spamassassin it seems -u 
>is optional for spamd.pid and I'm not even sure that's what it is 
>referring to.

>> communicates with spamd by localhost:783
>
>How do I force that?

don't.

>What I keep looking for (and fail to find) is a list of all actions I 
>need in order to set up spamass-milter - permissions, options, where 
>and what etc for ubuntu. Which is why I began this thread in the first 
>place.

don't change too many things, especially not once.

>And why do all the other milters I'm using not have this difficulty. :(

exactly the line above shows that spamass-milter is working. It clearly did
pass mail and the username (admin) to spamd.

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
The early bird may get the worm, but the second mouse gets the cheese.

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
As I understand it, altering those values in default/spamass-milter 
should be sufficient? Those have been changed for several days now.

Following a lead from elsewhere I have altered the owner to 
spamass-milter:postfix and the socket permissions follow it in the file 
manager. However, the PID file is being created with 
spamass-milter:nogroup and I cannot find where to change it - and does 
it matter in this case?

In System Monitor (task manager) I'm seeing (currently) 2 spamd 
processes, 2 spamd-child and a spamass-milter. Is that reasonable?

I'm also seeing the following in the log for each email email...

   spamd: connection from ::1 [::1]:55492 to port 783, fd 5
   spamd: handle_user (getpwnam) unable to find user: 'admin'
   spamd: still running as root: user not specified with -u, not found, 
or set to root, falling back to nobody
   spamd: processing message <message-id> for admin:65534š

... where admin changes according to the target email address (eg james, 
ebay etc) - I do not understand why line 2 is seeking user: admin.

Line 1 is using ipv6 - how can I force ipv4?

line 3 running as root - according to default/spamassassin it seems -u 
is optional for spamd.pid and I'm not even sure that's what it is 
referring to.

 > communicates with spamd by localhost:783

How do I force that?

What I keep looking for (and fail to find) is a list of all actions I 
need in order to set up spamass-milter - permissions, options, where and 
what etc for ubuntu. Which is why I began this thread in the first place.

And why do all the other milters I'm using not have this difficulty. :(


Re: Getting spamass-milter to work with postfix

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
On 17.11.19 18:38, Linkcheck wrote:
>Thank you for your responses. Sorry it's taken a while to reply.

no problem.

>Bearing in mind your comments - and those of the other contributors - 
>I now have the following setup / observations but I still can't get it 
>to work.
>
>/etc/default/spamassassin
>  ENABLED=1
>  OPTIONS="--create-prefs --maxchildren 5 -- helper-home-dir"
>  PIDFILE="/var/run/spamass/spamd.pid"
>
>/etc/default/spamass-milter
>  OPTIONS="-u spamass-milter -i 127.0.0.1"
>  SOCKET="/var/run/spamass/spamass.sock"
>  SOCKETOWNER="postfix:postfix"
>  SOCKETMODE="0660"
>
>As I understand it, the above values over-ride those in the init.d 
>files of relevant name, but I have in any case put the same values at 
>the top of those files.
>
>Before the ENABLED line in /etc/default/spamassassin is a 
>recommendation to run the command...
>  systemctl enable spamassassin.service
>
>This results in the following...
>
>Synchronizing state of spamassassin.service with SysV init with 
>/lib/systemd/systemd-sysv-install...
>Executing /lib/systemd/systemd-sysv-install enable spamassassin
>insserv: fopen(.depend.stop): Permission denied
>insserv: fopen(.depend.stop): Permission denied
>Failed to execute operation: Access denied

this is strange, are you running this as root?

>...and a perpetual failure to authenticate.
>
>I looked into replacing unix:/var/run/spamass/spamass.sock with 
>inet:localhost:783 in main.cf (which I'm pretty sure is wrong!) and it 
>logged errors and refused mail.
>
>By using unix:/var/run/spamass/spamass.sock in main.cf I have the 
>warning in the log: No such file or directory.

note that there are/may be two sockets:

1. milter socket for communicating between postfix and spamass-milter;
It's defined by SOCKET option in spamass-milter init.d/default file
and postfix *_milters option

2.  spamd socket for communication between spamass-milter and spamd. 
configured with --socketpath spamd option in default file and within spamc
options in spamass-milter after "--" in spamass-milter OPTIONS
- this socket is not used by default.

for example my spamass-milter options are:

OPTIONS="-i 127.0.0.1 -r 9 -m -u abuse -x -- -x -d 127.0.0.1 -s 20971520"

I don't use the latter socket, instead spamass-milter calls spamc that
communicates with spamd by localhost:783

However, my MTA communicates with milter via default socket (I haven't
overridden SOCKET in spamass-milter file).

just I don't use postfix on this machine, but sendmail that has no problems
communicating with /var/run/spamass/spamass.sock which is the default unless
debian init script finds /usr/sbin/postfix executable.

So, you should NOT use inet:localhost:783 for milter socket, since it's not
the milter, but the spamd socket.

find out which socket has spamass-milter open and try connecting postfix to
that one.

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
If Barbie is so popular, why do you have to buy her friends?

Re: Getting spamass-milter to work with postfix

Posted by Benny Pedersen <me...@junc.eu>.
Linkcheck skrev den 2019-11-17 23:49:
> Thanks for the response.
> 
>>> I looked into replacing unix:/var/run/spamass/spamass.sock with
>>> inet:localhost:783 in main.cf (which I'm pretty sure is wrong!)
>>> and it logged errors and refused mail.
>> glibc have ipv6 prefered over ipv4, so if spamd only listen on ipv4 ?
>> change localhost with [127.0.0.1] solves it
> 
> Reason I thought it was wrong is: I thought I was actually assigning
> spamd when I should be assigning spamass sock. Am I wrong in that
> assumption? If  I am I'll try it ASAP - it's a live server so I need
> to pick a quiet time.

i lost that localhost is aswell the spamass socket aswell as spamd. just 
diffrent ports ofcourse

>> ls -l
> drwxrwxr-x  2 postfix    postfix      40 Nov  5 19:45 spamass
> (nothing in folder)

socket can only be created here if spamas-milter starts as root and drop 
priveleges later, this is what dovecot do with dovecot sasl sockets, but 
if spamass-milter does not start as root then you can only use inet not 
unix

mail route will be internet > postfix smtpd > spamass-milter inet > 
spamc client > spamd inet

no unix socket needed

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
Thanks for the response.

 >> I looked into replacing unix:/var/run/spamass/spamass.sock with
 >> inet:localhost:783 in main.cf (which I'm pretty sure is wrong!)
 >> and it logged errors and refused mail.
 > glibc have ipv6 prefered over ipv4, so if spamd only listen on ipv4 ?
 > change localhost with [127.0.0.1] solves it

Reason I thought it was wrong is: I thought I was actually assigning 
spamd when I should be assigning spamass sock. Am I wrong in that 
assumption? If  I am I'll try it ASAP - it's a live server so I need to 
pick a quiet time.

 > ls -l
drwxrwxr-x  2 postfix    postfix      40 Nov  5 19:45 spamass
(nothing in folder)

-- 
Dave Stiles

Re: Getting spamass-milter to work with postfix

Posted by Benny Pedersen <me...@junc.eu>.
Linkcheck skrev den 2019-11-17 19:38:

> I looked into replacing unix:/var/run/spamass/spamass.sock with
> inet:localhost:783 in main.cf (which I'm pretty sure is wrong!) and it
> logged errors and refused mail.

glibc have ipv6 prefered over ipv4, so if spamd only listen on ipv4 ?

change localhost with [127.0.0.1] solves it

> By using unix:/var/run/spamass/spamass.sock in main.cf I have the
> warning in the log: No such file or directory.

ls -l that path would be nice to see

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
Thank you for your responses. Sorry it's taken a while to reply.

Bearing in mind your comments - and those of the other contributors - I 
now have the following setup / observations but I still can't get it to 
work.

/etc/default/spamassassin
   ENABLED=1
   OPTIONS="--create-prefs --maxchildren 5 -- helper-home-dir"
   PIDFILE="/var/run/spamass/spamd.pid"

/etc/default/spamass-milter
   OPTIONS="-u spamass-milter -i 127.0.0.1"
   SOCKET="/var/run/spamass/spamass.sock"
   SOCKETOWNER="postfix:postfix"
   SOCKETMODE="0660"

As I understand it, the above values over-ride those in the init.d files 
of relevant name, but I have in any case put the same values at the top 
of those files.

Before the ENABLED line in /etc/default/spamassassin is a recommendation 
to run the command...
   systemctl enable spamassassin.service

This results in the following...

Synchronizing state of spamassassin.service with SysV init with 
/lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable spamassassin
insserv: fopen(.depend.stop): Permission denied
insserv: fopen(.depend.stop): Permission denied
Failed to execute operation: Access denied

...and a perpetual failure to authenticate.

I looked into replacing unix:/var/run/spamass/spamass.sock with 
inet:localhost:783 in main.cf (which I'm pretty sure is wrong!) and it 
logged errors and refused mail.

By using unix:/var/run/spamass/spamass.sock in main.cf I have the 
warning in the log: No such file or directory.

Re: Getting spamass-milter to work with postfix

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
>On 13.11.19 12:01, Linkcheck wrote:
>>I was rather hoping someone could supply a basic setup that would 
>>allow spamass-milter to run with postfix, which is why I originally 
>>posted so much information.


On 13.11.19 14:12, Matus UHLAR - fantomas wrote:
>You mention having Mint (Ubuntu 16).  Ubuntu 16 also uses chroot for smtpd
>by default:
>
># service type  private unpriv  chroot  wakeup  maxproc command + args
>#               (yes)   (yes)   (no)    (never) (100)
># ==========================================================================
>smtp      inet  n       -       y       -       -       smtpd

this may be the issue.
I looked into debians' /etc/init.d/spamass-milter and it contains following
code:

# If /usr/sbin/postfix exists, set up the defaults for a postfix install
# These can be overridden in /etc/default/spamass-milter
if [ -x /usr/sbin/postfix ]; then
    SOCKET="/var/spool/postfix/spamass/spamass.sock"
    SOCKETOWNER="postfix:postfix"
    SOCKETMODE="0660"
fi;

maybe your script contains the same and you need to override sock file
there...
-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
LSD will make your ECS screen display 16.7 million colors

Re: Getting spamass-milter to work with postfix

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
>On 11/11/2019 19:23, Benny Pedersen wrote:
>>i am confused from your first post where you show spamPd and spamD 
>>config files

On 13.11.19 12:01, Linkcheck wrote:
>I posted all I could find relating to spamassassin. I missed chroot, 
>which never occurred to me might be relevant since I've never applied 
>it.

>>spamPd is a smtp proxy that does not require spamD to run at all

>I find it confusing trying to determine what part of spamassassin IS 
>relevant to my requirement.

FYI spampd is not part of spamassassin.

>I was rather hoping someone could supply a 
>basic setup that would allow spamass-milter to run with postfix, which 
>is why I originally posted so much information.

I use spamass-milter only with sendmail.  My postfix machines use
amavisd-milter.  And they are on debian, which uses chroot for smtpd by
default.

I am trying to help as much as I can, and seems nobody who replies yet runs
your combination of SW.

>>spamass-milter does not use spamPd but only spamc
>
>So how would I specify that, please?

you don't have to, it executes spamc automatically.

>>netstat -natpu
>
>Thanks for the hint. Still does not resolve my confusion concerning 
>what else to set up, though.

BTW.

You mention having Mint (Ubuntu 16).  Ubuntu 16 also uses chroot for smtpd
by default:

# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (no)    (never) (100)
# ==========================================================================
smtp      inet  n       -       y       -       -       smtpd


-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Atheism is a non-prophet organization.

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
On 11/11/2019 19:23, Benny Pedersen wrote:
> i am confused from your first post where you show spamPd and spamD 
> config files

I posted all I could find relating to spamassassin. I missed chroot, 
which never occurred to me might be relevant since I've never applied it.

> spamPd is a smtp proxy that does not require spamD to run at all

I find it confusing trying to determine what part of spamassassin IS 
relevant to my requirement. I was rather hoping someone could supply a 
basic setup that would allow spamass-milter to run with postfix, which 
is why I originally posted so much information.

> spamass-milter does not use spamPd but only spamc

So how would I specify that, please?

> netstat -natpu

Thanks for the hint. Still does not resolve my confusion concerning what 
else to set up, though.

-- 
Dave Stiles

Re: Getting spamass-milter to work with postfix

Posted by Benny Pedersen <me...@junc.eu>.
Linkcheck skrev den 2019-11-11 20:11:
> On 10/11/2019 20:15, Benny Pedersen wrote:
>> then use milter in postfix to inet:[127.0.0.1]:spamass-milter-port
> 
> How do I find the spamass port? Is it the spamd DESTPORT? I assume I
> then have to add the LISTENPORT into master.cf?

i am confused from your first post where you show spamPd and spamD 
config files

spamPd is a smtp proxy that does not require spamD to run at all

spamass-milter does not use spamPd but only spamc

to find listen inet ports

netstat -natpu

i can not help more now

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
On 10/11/2019 20:15, Benny Pedersen wrote:
> then use milter in postfix to inet:[127.0.0.1]:spamass-milter-port

How do I find the spamass port? Is it the spamd DESTPORT? I assume I 
then have to add the LISTENPORT into master.cf?

Re: Getting spamass-milter to work with postfix

Posted by Benny Pedersen <me...@junc.eu>.
Linkcheck skrev den 2019-11-07 16:25:

> /etc/default/spamass-milter
>   OPTIONS="-u spamass-milter -i 127.0.0.1"

then use milter in postfix to inet:[127.0.0.1]:spamass-milter-port

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
 > "with postfix, you may need to set up milter wocket within its chroot"

Ok, but since I do NOT use chroot which should I set up, bearing in mind 
the other milters all run successfully?

My original posting gives my setup AS FAR AS I CAN DISCOVER IT. 
Presumably something in it is incorrect or I have a wrong permission.

Re: Getting spamass-milter to work with postfix

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
>> with postfix, you need to set up milter wocket within its chroot.
>> on debian/ubuntu consult  /etc/default/spamass-milter

On 11.11.19 16:40, Linkcheck wrote:
>Elsewhere I've read the opposite. It does not sound reasonable anyway: 
>clam, opendkim etc work without chroot.

maybe the postfix smtpd is run on your system without chroot. May not be
true on the OPs system. Let's change it to:

"with postfix, you may need to set up milter wocket within its chroot"

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
I feel like I'm diagonally parked in a parallel universe.

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
On 11/11/2019 19:15, Reindl Harald wrote:
> because it's common sense

Sorry, but that is NOT an explanation.

>>> when postfix is configured to a unix socket which is a path it needs to
>>> live within the chroot postfix is using
>> I am not using chroot
> then why did you respond at all to something talking about postfix with
> the chroot column in master.cf not explicit disabled - default is
> *enabled*  even when you don't now it

I have not posted anything from master.cf at all. If I had it would have 
shown that the chroot column has "n" in it. It always has.

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
 > with postfix, you need to set up milter wocket within its chroot.
 > on debian/ubuntu consult  /etc/default/spamass-milter

Elsewhere I've read the opposite. It does not sound reasonable anyway: 
clam, opendkim etc work without chroot.

-- 
Dave Stiles

Re: Getting spamass-milter to work with postfix

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
On 10.11.19 15:55, Linkcheck wrote:
>I've tried altering things but the best I can get is the message:
>  "warning: connect to Milter service 
>unix:/var/run/spamass/spamass.sock: No such file or directory"
>
>The folder exists with the permissions postfix:postfix 0660. I have 
>also tried spamass-milter:postfix.

with postfix, you need to set up milter wocket within its chroot.
on debian/ubuntu consult  /etc/default/spamass-milter

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Linux is like a teepee: no Windows, no Gates and an apache inside...

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
On 18/11/2019 10:46, Edda wrote:
> You did not start/restart spamass-milter?

I found no mention of such a thing, although I did look and concluded 
there was no such thing. This has been my problem all along: lots of 
Howto Install but always missing vital bits. :(

Searching now, I found how to start the milter - it didn't work until I 
ran "adduser spamass-milter:spamd". That led me to a few other things 
but still not working properly, although something is working: 
spamassassin runs and gives an expected output and the sequence is now: 
SPF, DKIM, DMARC, SPAMD.

Then I had to find...
  postconf milter_connect_macros="i j {daemon_name} v {if_name} _"
...and add that into main.cf.

However, I'm still getting a warning...
   Could not retrieve sendmail macro "i"!.
   Please add it to confMILTER_MACROS_ENVFROM

Haven't yet found where that is.

> lsof <pid of spamass-milter>

Gives what you suggest, although not the same details, obviously.

> That's the socket for your postfix configuration (main.cf)
> smtpd_milters = unix:/var/run/spamass/spamass.sock [...]

Which is what I have in main.cf

Thanks for your input. Appreciated.

Re: Getting spamass-milter to work with postfix

Posted by Edda <le...@sendmaid.org>.
Am 10.11.19 um 16:55 schrieb Linkcheck:
> I've tried altering things but the best I can get is the message:
>   "warning: connect to Milter service 
> unix:/var/run/spamass/spamass.sock: No such file or directory"

This is the socket the spamass-milter daemon has to create for postfix 
to communicate with.

>
> No matter how I start postfix and spamassassin, /var/run/spamass 
> remains empty but spamassassin.pid is rewritten to /var/run.
>
> I am restarting using:
>   sudo service postfix restart
>   sudo service spamassassin restart
>
> I suspect is not spass-milter is not being started?
>
You did not start/restart spamass-milter?

Start/Restart spamass-milter and look for the socket it has created:

lsof <pid of spamass-milter>

There should be something like this in the output:

spamass-m 1711 spamass-milter    4u  unix 0xffff88003aaf0400 0t0  18591 
/var/run/spamass/spamass.sock type=STREAM

That's the socket for your postfix configuration (main.cf)

smtpd_milters = unix:/var/run/spamass/spamass.sock [...]

Best regards,
Edda

Re: Getting spamass-milter to work with postfix

Posted by Linkcheck <sp...@linkcheck.co.uk>.
I've tried altering things but the best I can get is the message:
   "warning: connect to Milter service 
unix:/var/run/spamass/spamass.sock: No such file or directory"

The folder exists with the permissions postfix:postfix 0660. I have also 
tried spamass-milter:postfix.

On restarting spamassassin, whether as a content filter or a milter, I get:
   "spamd: server started on IO::Socket::IP [::1]:783, IO::Socket::IP 
[127.0.0.1]:783"

In the three spamxxx files in /etc/default I now have socket and pid as...

/etc/default/spamassassin
   PIDFILE="/var/run/spamass/spamd.pid"

/etc/default/spamass-milter
   OPTIONS="-u spamass-milter -i 127.0.0.1 -m -I -- 
--socket=/var/run/spamass/spamd.sock"
   SOCKET="/var/run/spamass/spamass.sock"
   SOCKETOWNER="postfix:postfix"
   SOCKETMODE="0660"

/etc/default/spampd
  PIDFILE=/var/run/spamass/spamd.pid

No matter how I start postfix and spamassassin, /var/run/spamass remains 
empty but spamassassin.pid is rewritten to /var/run.

I am restarting using:
   sudo service postfix restart
   sudo service spamassassin restart

I suspect is not spass-milter is not being started?

-- 
Dave Stiles