You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by PGNet Dev <pg...@gmail.com> on 2020/06/09 23:27:01 UTC

sa 3.4.4 'spamassassin' scores test message using local.cf; 'spamd' finds/reads local.cg, but 'spamc' of test msg fails to hit/score?

I'm setting up a local/standalone instance spamd on linux

	lsb_release -rd
		Description:    openSUSE Leap 15.1
		Release:        15.1

	uname -rm
		5.7.1-25.gc4df4ce-default x86_64

	perl -v
		This is perl 5, version 26, subversion 1 (v5.26.1) built for x86_64-linux-thread-multi

I've built/installed

	ls -al `which spamassassin` `which spamd` `which spamc`
		-r-xr-xr-x 1 root root  30K Jun  9 10:05 /usr/bin/spamassassin*
		-r-xr-xr-x 1 root root  60K Jun  9 10:05 /usr/bin/spamc*
		-r-xr-xr-x 1 root root 128K Jun  9 10:05 /usr/bin/spamd*

	spamassassin -V
		SpamAssassin version 3.4.4
		  running on Perl version 5.26.1
	spamd -V
		SpamAssassin Server version 3.4.4
		  running on Perl 5.26.1
		  with SSL support (IO::Socket::SSL 2.067)
		  with zlib support (Compress::Zlib 2.093)
	spamc -V
		SpamAssassin Client version 3.4.4
		  compiled with SSL support (OpenSSL 1.1.1g  21 Apr 2020)

cleaning old data

	cd /var/lib/spamassassin
	rm -f updates_spamassassin_org.cf
	rm -rf updates_spamassassin_org/*
	rm -rf 3.00*
	rm -rf compiled*

updating/compiling,

	/usr/bin/sudo -u spamd \
	/usr/bin/sa-update -D \
	--channel updates.spamassassin.org \
	--allowplugins \
	--reallyallowplugins \
	--refreshmirrors

	/usr/bin/sudo -u spamd \
	 /usr/bin/sa-compile -D \
	 --siteconfigpath=/usr/local/etc/spamassassin

populates

	tree 3.004004/ compiled/
		3.004004/
		├── updates_spamassassin_org
		│   ├── 10_default_prefs.cf
		│   ├── 10_hasbase.cf
		... 

		│   ├── 60_whitelist_subject.cf
		│   ├── 72_active.cf
		│   ├── 72_scores.cf
		│   ├── 73_sandbox_manual_scores.cf
		│   ├── languages
		│   ├── local.cf
		│   ├── MIRRORED.BY
		│   ├── regression_tests.cf
		│   ├── sa-update-pubkey.txt
		│   ├── STATISTICS-set0-72_scores.cf.txt
		│   ├── STATISTICS-set1-72_scores.cf.txt
		│   ├── STATISTICS-set2-72_scores.cf.txt
		│   ├── STATISTICS-set3-72_scores.cf.txt
		│   └── user_prefs.template
		└── updates_spamassassin_org.cf
		compiled/
		└── 5.026
		    └── 3.004004
		        ├── auto
		        │   └── Mail
		        │       └── SpamAssassin
		        │           └── CompiledRegexps
		        │               ├── body_0
		        │               │   └── body_0.so
		        │               ├── body_neg1000
		        │               │   └── body_neg1000.so
		        │               └── body_neg300
		        │                   └── body_neg300.so
		        ├── bases_body_0.pl
		        ├── bases_body_neg1000.pl
		        ├── bases_body_neg300.pl
		        └── Mail
		            └── SpamAssassin
		                └── CompiledRegexps
		                    ├── body_0.pm
		                    ├── body_neg1000.pm
		                    └── body_neg300.pm

		13 directories, 77 files


using the "sample-spam" GTUBE file,

	wget http://svn.apache.org/repos/asf/spamassassin/trunk/sample-spam.txt

testing 'spamassassin', returns as expected

	spamassassin -D -t < sample-spam.txt
		...
		 pts rule name              description
		---- ---------------------- --------------------------------------------------
		1000 GTUBE                  BODY: Generic Test for Unsolicited Bulk Email
		-0.0 NO_RELAYS              Informational: message was not relayed via SMTP
		-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
		                            [score: 0.0000]
		 3.0 DCC_CHECK              Detected as bulk mail by DCC (dcc-servers.net)
		-0.0 NO_RECEIVED            Informational: message has no Received headers
		 0.0 FSL_BULK_SIG           Bulk signature with no Unsubscribe

		Jun  9 15:22:44.510 [26682] dbg: check: tagrun - tag SENDERDOMAIN is still blocking action 2
		Jun  9 15:22:44.510 [26682] dbg: check: tagrun - tag DKIMDOMAIN is still blocking action 0
		Jun  9 15:22:44.511 [26682] dbg: plugin: Mail::SpamAssassin::Plugin::MIMEHeader=HASH(0x55ec83b68860) implements 'finish_tests', priority 0
		Jun  9 15:22:44.511 [26682] dbg: plugin: Mail::SpamAssassin::Plugin::Check=HASH(0x55ec83b68e60) implements 'finish_tests', priority 0

next, launching 'spamd', 

	/usr/bin/sudo -u spamd \
	/usr/bin/spamd -D \
	 --configpath=/usr/local/etc/spamassassin \
	 --nouser-config \
	 --listen=/run/spamd/spamd.sock \
	 --pidfile=/run/spamd/spamd.pid \
	 --username=spamd \
	 --groupname=spamd \
	  --socketowner=spamd \
	  --socketgroup=spamd \
	  --socketmode=775

DOES find/read my 'local.sf', and starts

	...
	Jun  9 16:04:29.813 [32688] dbg: generic: SpamAssassin version 3.4.4
	Jun  9 16:04:29.814 [32688] dbg: generic: Perl 5.026001, PREFIX=/usr, DEF_RULES_DIR=/var/lib/spamassassin, LOCAL_RULES_DIR=/usr/local/etc/spamassassin, LOCAL_STATE_DIR=/var/lib/spamassassin
	...
	Jun  9 16:04:29.818 [32688] dbg: config: using "/usr/local/etc/spamassassin" for site rules pre files
	...
	Jun  9 16:04:29.820 [32688] dbg: config: using "/usr/local/etc/spamassassin" for sys rules pre files
	...
	Jun  9 16:04:29.822 [32688] dbg: config: using "/usr/local/etc/spamassassin" for default rules dir
	Jun  9 16:04:29.822 [32688] dbg: config: read file /usr/local/etc/spamassassin/local.cf
	...
	Jun  9 16:04:29.823 [32688] dbg: config: using "/usr/local/etc/spamassassin" for site rules dir
	Jun  9 16:04:29.823 [32688] dbg: config: read file /usr/local/etc/spamassassin/local.cf
	...
	Jun  9 16:04:30.688 [32688] info: spamd: server started on UNIX domain socket /run/spamd/spamd.sock (running version 3.4.4)
	...

	ps ax | grep spamd
		32686 pts/1    S+     0:00 /usr/bin/sudo -u spamd /usr/bin/spamd -D --configpath=/usr/local/etc/spamassassin --nouser-config --listen=/run/spamd/spamd.sock --pidfile=/run/spamd/spamd.pid --username=spamd --groupname=spamd --socketowner=spamd --socketgroup=spamd --socketmode=775
		32688 pts/1    S+     0:01 /usr/bin/perl -w /usr/bin/spamd -D --configpath=/usr/local/etc/spamassassin --nouser-config --listen=/run/spamd/spamd.sock --pidfile=/run/spamd/spamd.pid --username=spamd --groupname=spamd --socketowner=spamd --socketgroup=spamd --socketmode=775
		32692 pts/1    S+     0:00 spamd child                                                                                                                                                                                                                    
		32693 pts/1    S+     0:00 spamd child                   


but, with this 'spamc' config,

	cat /usr/local/etc/spamassassin/spamc.conf
		--config=/usr/local/etc/spamassassin/local.cf
		--socket=/run/spamd/spamd.sock
		--no-safe-fallback
		--max-size=1000000
		--username spamd
		--log-to-stderr

a test with 'spamc' passes to 'spamd', but fails to score the message

	spamc < sample-spam.txt
		...
		X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable
		        autolearn_force=no version=3.4.4
		...

	journalctl -f | grep spam

		Jun 09 15:42:28 dev.loc spamd[29742]: spamd: got connection over /run/spamd/spamd.sock
		Jun 09 15:42:28 dev.loc spamd[29742]: spamd: processing message <GT...@example.net> for spamd:5128
		Jun 09 15:42:28 dev.loc spamd[29742]: spamd: clean message (0.0/5.0) for spamd:5128 in 0.0 seconds, 799 bytes.
		Jun 09 15:42:28 dev.loc spamd[29742]: spamd: result: . 0 - scantime=0.0,size=799,user=spamd,uid=5128,required_score=5.0,rhost=localhost,raddr=127.0.0.1,rport=/run/spamd/spamd.sock,mid=<GT...@example.net>,autolearn=unavailable autolearn_force=no,shortcircuit=no
		Jun 09 15:42:28 dev.loc spamd[29738]: prefork: child states: II

hitting NO tests

	tests=none 


this should work; i've missed something.

what different/additional config is needed to get 'spamc' to USE the config'd tests that 'spamd' supposedly picks up from my sitewide local.cf?


Re: sa 3.4.4 'spamassassin' scores test message using local.cf; 'spamd' finds/reads local.cg, but 'spamc' of test msg fails to hit/score?

Posted by RW <rw...@googlemail.com>.
On Tue, 9 Jun 2020 16:27:01 -0700
PGNet Dev wrote:


> next, launching 'spamd', 
> 

> 	 --configpath=/usr/local/etc/spamassassin \

If you need this line you are doing something strange.

You are overriding the default config location with the default site
config location. There's not much there anymore, but the config
location used to be where the rules went when they were updated by
package rather than sa-update - it's for installed files.

Also, the last time I checked, you still need to pass '-u  spamd' even
if you start spamd as that user.

> but, with this 'spamc' config,
> 
> 	cat /usr/local/etc/spamassassin/spamc.conf
> 		--config=/usr/local/etc/spamassassin/local.cf
> 		--socket=/run/spamd/spamd.sock
> 		--no-safe-fallback
> 		--max-size=1000000
> 		--username spamd
> 		--log-to-stderr

You are passing a mixture of spamd and spamc arguments to spamc. 

You are also treating --username as if it were an argument to spamd
where it's the unprivileged user. In spamc it's the user for 'per user'
features - you shouldn't need it.



Re: sa 3.4.4 'spamassassin' scores test message using local.cf; 'spamd' finds/reads local.cg, but 'spamc' of test msg fails to hit/score?

Posted by RW <rw...@googlemail.com>.
On Tue, 9 Jun 2020 19:55:24 -0700
PGNet Dev wrote:

> sorry, that's unclear
> 
> spamc --help | egrep "config|socket|fallback|size|username|log-to"
>   -U, --socket path   Connect to spamd via UNIX domain sockets.
>   -F, --config path   Use this configuration file.
>                       Try connecting to spamd tcp socket this many
> times -s, --max-size size Specify maximum message size, in bytes.
>   -u, --username username
>   -x, --no-safe-fallback
>                       Don't fallback safely.
>   -l, --log-to-stderr Log errors and warnings to stderr.
> 
> 
> just to be clear, which of those options is not a spamc option?

Looking at it again there is only one other beside -u. 

  -F, --config path 

is for spamc configuration not the spamassassin/spamd configuration.
It's for use on the command line. 

Re: sa 3.4.4 'spamassassin' scores test message using local.cf; 'spamd' finds/reads local.cg, but 'spamc' of test msg fails to hit/score?

Posted by PGNet Dev <pg...@gmail.com>.
On 6/9/20 7:45 PM, PGNet Dev wrote:
> RW Tue, 09 Jun 2020 17:15:49 -0700
> If you need this line you are doing something strange.

always happy to simplify.

rm'ing

	--configpath=/usr/local/etc/spamassassin \

from spamd launch, I still see

	...
	Jun 09 19:44:41 dev.loc spamd[57610]: config: read file /usr/local/etc/spamassassin/local.cf
	Jun 09 19:46:31 dev.loc spamd[57731]: config: using "/usr/local/etc/spamassassin" for site rules pre files
	Jun 09 19:46:31 dev.loc spamd[57731]: config: read file /usr/local/etc/spamassassin/init.pre
	Jun 09 19:46:31 dev.loc spamd[57731]: config: read file /usr/local/etc/spamassassin/sh.pre
	Jun 09 19:46:31 dev.loc spamd[57731]: config: read file /usr/local/etc/spamassassin/v310.pre
	Jun 09 19:46:31 dev.loc spamd[57731]: config: read file /usr/local/etc/spamassassin/v312.pre
	...

so that's good.


> Also, the last time I checked, you still need to pass '-u  spamd' even
> 
> if you start spamd as that user.

it's already 'in there'

	--username=spamd \

	--groupname=spamd \

where,

spamd --help | egrep "\-u|\-g"
     -u username, --username=username  Run as username
     -g groupname, --groupname=groupname  Run as groupname

> 
>> but, with this 'spamc' config,
> 
>>
> 
>>        cat /usr/local/etc/spamassassin/spamc.conf
> 
>>                --config=/usr/local/etc/spamassassin/local.cf
> 
>>                --socket=/run/spamd/spamd.sock
> 
>>                --no-safe-fallback
> 
>>                --max-size=1000000
> 
>>                --username spamd
> 
>>                --log-to-stderr
> 
> 
> 
> You are passing a mixture of spamd and spamc arguments to spamc.

sorry, that's unclear

spamc --help | egrep "config|socket|fallback|size|username|log-to"
  -U, --socket path   Connect to spamd via UNIX domain sockets.
  -F, --config path   Use this configuration file.
                      Try connecting to spamd tcp socket this many times
  -s, --max-size size Specify maximum message size, in bytes.
  -u, --username username
  -x, --no-safe-fallback
                      Don't fallback safely.
  -l, --log-to-stderr Log errors and warnings to stderr.


just to be clear, which of those options is not a spamc option?

> You are also treating --username as if it were an argument to spamd
> 
> where it's the unprivileged user. In spamc it's the user for 'per user'
> 
> features - you shouldn't need it.

ok, removing it.

-	--username spamd


and, now,

spamc < sample-spam.txt

	X-Spam-Status: Yes, score=1003.0 required=5.0 tests=DCC_CHECK,FSL_BULK_SIG,
        GTUBE,NO_RECEIVED,NO_RELAYS autolearn=disabled version=3.4.4


::facepalm:: !

ta!! o/