You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Jerry Malcolm <te...@malcolms.com> on 2019/11/22 18:14:13 UTC

Where is SA getting config info?

I am trying to add bayes to SA.  I see in the docs that there is a 
use_bayes parm and the path parm.  I made the changes to 
/usr/share/spamassassin/local.cf.  But I see no change.  I am not sure 
it's even loading that config file. I've got debug on, and the log 
doesn't tell me that it's reading the local.cf file I'm changing.

I think I need to go back to the basics.  I simply want a 100% site-wide 
SA (no per-user anything).  I've read of the config docs. It describes 
every parameter.  But it doesn't really put the big picture together. Is 
there a "SpamAssassin for Dummies" doc that describes the command line 
args for 'site-wide-only' and also which config file (local.cf?) in 
which folder I should be changing?

The initial install of SA on AWS Linux EC2 has a SPAMDOPTIONS="-d -c -m5 
-H".  I was told a few months back in this forum that -H without a 
parameter following is not even valid and it applies to per-user stuff.  
So I removed the -H.  I read that -c creates a user pref file which 
sounds like per-user.  So I removed that. But the log is telling me it's 
loading files from /etc/mail which I thought the docs said was per-user 
stuff.  Basically, I can't figure out how to make any config changes 
that are actually seen by SA.

So... questions:

     -- first just to make SA run as 'site-wide-only', should the 
command line args be "-d -m5"? (or do I really need to go back to "-d -c 
-m5 -H"?

     -- What file should I be changing to adjust config?  If it's indeed 
/usr/share/spamassassin/local.cf, is there something I can change in 
there that I can force something in the log file to assure me that 
config parms are really being pulled from here?

     -- Shouldn't "use_bayes 1" cause something to appear in the debug 
log saying something about bayes now in use (and something about the 
bayes_toks file)?

     -- Finally, where should I put custom rule files such as KAM.cf so 
they are used, but not erased with sa_update?

If all of this is explained in some user scenario docs, please point me 
to them.  It's just really tough getting the big picture here especially 
when I can't get ANY config changes to make any difference.

Thx


Re: Where is SA getting config info?

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
>>On 22.11.19 12:14, Jerry Malcolm wrote:
>>>I am trying to add bayes to SA.  I see in the docs that there is a 
>>>use_bayes parm and the path parm.  I made the changes to 
>>>/usr/share/spamassassin/local.cf.

>On 11/22/2019 12:25 PM, Matus UHLAR - fantomas wrote:
>>the config files and rules are usually in /etc/spamassassin/

>>>But I see no change.  I am not sure it's even loading that config 
>>>file. I've got debug on, and the log doesn't tell me that it's 
>>>reading the local.cf file I'm changing.

>>try running spamassassin -D --lint and look for results:
>>
>>Nov 22 19:20:24.735 [16921] dbg: logger: adding facilities: all
>>Nov 22 19:20:24.735 [16921] dbg: logger: logging level is DBG
>>Nov 22 19:20:24.735 [16921] dbg: generic: SpamAssassin version 3.4.2
>>Nov 22 19:20:24.735 [16921] dbg: generic: Perl 5.028001, 
>>PREFIX=/usr, DEF_RULES_DIR=/usr/share/spamassassin, 
>>LOCAL_RULES_DIR=/etc/spamassassin, 
>>LOCAL_STATE_DIR=/var/lib/spamassassin

On 22.11.19 13:06, Jerry Malcolm wrote:
>My LOCAL_RULES_DIR is /etc/mail/spamassassin, and the log did say:
>
>            dbg: config: read file /etc/mail/spamassassin/local.cf
>
>I added:    bayes_path /etc/sysconfig/sa_bayes  line to 
>/etc/mail/spamassassin/local.cf, but the log said:
>
>            dbg: bayes: tie-ing to DB file R/O 
>/root/.spamassassin/bayes_toks
>
>It ignored the path I set.  Shouldn't it be using the bayes_path from 
>my local.cf?

It should. I have put bayes_path temporarily to /etc/spamassassin/local.cf
and it tried to use provided value.

as already noted, bayes_path is path prefix, not a directory, must point to
directory the spamd user has permission to write to and it shouldn't be in
/etc, I recommend somewhere in /var

>>>The initial install of SA on AWS Linux EC2 has a SPAMDOPTIONS="-d 
>>>-c -m5 -H".  I was told a few months back in this forum that -H 
>>>without a parameter following is not even valid and it applies to 
>>>per-user stuff.
>>
>>it _is_ valid and applies per-user config files.
>But even if I'm not using per-user, should I still add -H and -c back in?

they aren't needed then.

Note that "spamassassin" is standalone program and so it behaves differently
than "spamd". I recommended you using it to test system configuration.


-- 
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 wonder how much deeper the ocean would be without sponges.

Re: Where is SA getting config info?

Posted by RW <rw...@googlemail.com>.
On Fri, 22 Nov 2019 13:06:23 -0600
Jerry Malcolm wrote:

> I added:    bayes_path /etc/sysconfig/sa_bayes 

This means that your files will be created directly in /etc/sysconfig/
with the filename prefix sa_bayes. You need to specify a dedicated
directory to which your unprivileged user has read/write access.


/etc is a strange place to put a database.

Re: Where is SA getting config info?

Posted by Jerry Malcolm <te...@malcolms.com>.
Thanks for the quick response... see below:

On 11/22/2019 12:25 PM, Matus UHLAR - fantomas wrote:
> On 22.11.19 12:14, Jerry Malcolm wrote:
>> I am trying to add bayes to SA.  I see in the docs that there is a 
>> use_bayes parm and the path parm.  I made the changes to 
>> /usr/share/spamassassin/local.cf.
>
> the config files and rules are usually in /etc/spamassassin/
>
>> But I see no change.  I am not sure it's even loading that config 
>> file. I've got debug on, and the log doesn't tell me that it's 
>> reading the local.cf file I'm changing.
>
> try running spamassassin -D --lint and look for results:
>
> Nov 22 19:20:24.735 [16921] dbg: logger: adding facilities: all
> Nov 22 19:20:24.735 [16921] dbg: logger: logging level is DBG
> Nov 22 19:20:24.735 [16921] dbg: generic: SpamAssassin version 3.4.2
> Nov 22 19:20:24.735 [16921] dbg: generic: Perl 5.028001, PREFIX=/usr, 
> DEF_RULES_DIR=/usr/share/spamassassin, 
> LOCAL_RULES_DIR=/etc/spamassassin, LOCAL_STATE_DIR=/var/lib/spamassassin

My LOCAL_RULES_DIR is /etc/mail/spamassassin, and the log did say:

             dbg: config: read file /etc/mail/spamassassin/local.cf

I added:    bayes_path /etc/sysconfig/sa_bayes  line to 
/etc/mail/spamassassin/local.cf, but the log said:

             dbg: bayes: tie-ing to DB file R/O 
/root/.spamassassin/bayes_toks

It ignored the path I set.  Shouldn't it be using the bayes_path from my 
local.cf?

>> The initial install of SA on AWS Linux EC2 has a SPAMDOPTIONS="-d -c 
>> -m5 -H".  I was told a few months back in this forum that -H without 
>> a parameter following is not even valid and it applies to per-user 
>> stuff.
>
> it _is_ valid and applies per-user config files.
But even if I'm not using per-user, should I still add -H and -c back in?
>
>>   So I removed the -H.  I read that -c creates a user pref file which 
>> sounds like per-user.  So I removed that. But the log is telling me 
>> it's loading files from /etc/mail which I thought the docs said was 
>> per-user stuff. Basically, I can't figure out how to make any config 
>> changes that are actually seen by SA.
>
> you thought wrong, I don't know where did you get that info.
> /etc/ stores system-wide settings on UN*X systems.
>
>>     -- Finally, where should I put custom rule files such as KAM.cf 
>> so they are used, but not erased with sa_update?
>
> see LOCAL_RULES_DIR in your debug output 

Re: Where is SA getting config info?

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
On 22.11.19 12:14, Jerry Malcolm wrote:
>I am trying to add bayes to SA.  I see in the docs that there is a 
>use_bayes parm and the path parm.  I made the changes to 
>/usr/share/spamassassin/local.cf.

the config files and rules are usually in /etc/spamassassin/

> But I see no change.  I am not sure 
>it's even loading that config file. I've got debug on, and the log 
>doesn't tell me that it's reading the local.cf file I'm changing.

try running spamassassin -D --lint and look for results:

Nov 22 19:20:24.735 [16921] dbg: logger: adding facilities: all
Nov 22 19:20:24.735 [16921] dbg: logger: logging level is DBG
Nov 22 19:20:24.735 [16921] dbg: generic: SpamAssassin version 3.4.2
Nov 22 19:20:24.735 [16921] dbg: generic: Perl 5.028001, PREFIX=/usr, DEF_RULES_DIR=/usr/share/spamassassin, LOCAL_RULES_DIR=/etc/spamassassin, LOCAL_STATE_DIR=/var/lib/spamassassin

>The initial install of SA on AWS Linux EC2 has a SPAMDOPTIONS="-d -c 
>-m5 -H".  I was told a few months back in this forum that -H without a 
>parameter following is not even valid and it applies to per-user 
>stuff.

it _is_ valid and applies per-user config files.

>  So I removed the -H.  I read that -c creates a user pref file 
>which sounds like per-user.  So I removed that. But the log is telling 
>me it's loading files from /etc/mail which I thought the docs said was 
>per-user stuff.  Basically, I can't figure out how to make any config 
>changes that are actually seen by SA.

you thought wrong, I don't know where did you get that info.
/etc/ stores system-wide settings on UN*X systems.

>    -- Finally, where should I put custom rule files such as KAM.cf so 
>they are used, but not erased with sa_update?

see LOCAL_RULES_DIR in your debug output 
-- 
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.
Microsoft dick is soft to do no harm

Re: bayes_toks location when running as a service

Posted by Bob D <bo...@inter-control.com>.
Yes, you are correct Martin.
Jerry, your sandboxes are not equal for testing. How you got one systemd 
and another systemv is unknown. You should make sure they are equal for 
testing.
According to Amazon:
"The redhat-lsb package is available in the Amazon Linux AMI 
repositories, but it is not part of the default AMI package set. The 
same is true of the binutils package, which can be installed on its own 
with "yum install binutils" or as part of the large dependency chain 
that will be brought in by installing redhat-lsb.
The reason why neither of these packages are on the default Amazon Linux 
AMI is because one of our goals with the Amazon Linux AMI is to keep the 
base package set as minimal as possible, while making it easy for people 
to extend the AMI."

This explains the issue at hand.
I am currently wrestling with Debian 10 on nvme-ssd drives raided. 
(nightmare)
It is sytemd however, it retains duplicate systemv and is supposed to be 
compatible. The same is true with the latest Ubuntu's.
Amazon's systemd apparently is not backwards compatible.


On 11/23/19 2:02 PM, Martin Gregorie wrote:
> On Sat, 2019-11-23 at 13:07 -0600, Jerry Malcolm wrote:
>> Bob & John.... Thanks so much for the info.  But as if I wasn't dazed
>> & confused enough already, I have discovered a new variable to the
>> whole thing.  I have set up a couple of sandbox EC2 instances just to
>> play.  I didn't realize it at first, but one is AWS Linux 1 and the
>> other is AWS Linux 2.  And the whole startup file structure is
>> different between the two.  The Linux 1 env does indeed have
>> /etc/init.d/spamassassin.  But I don't see anything that looks like
>> it's setting a user to 'spamd'.  In
>> the Linux 2 env, I have:
>>
>> /usr/lib/systemd/system/spamassassin.service that starts
>> /usr/bin/spamd
>> using options file /etc/sysconfig/spamassassin
>>
> That tells is that the AWS Linux 1 system uses the good old sysVinit
> system for starting/stopping and controlling system services - its
> virtually unchanged since it first appeared in Unix SVr4, while the AWS
> Linux 2 system is using the newer Systemd in its place.
>
> Systemd appeared in  RedHat Linux's Fedora (their free distro) a few
> years back when Fedora 20 was released and is a totally different beast.
> Its gradually replaced SysvInit in all the main distros since then, so
> now there only a few sysVinit based Linuxes and these are used by the
> remaining systemd holdouts.
>
> There's a decent documentation set for systemd here:
> https://www.freedesktop.org/wiki/Software/systemd/
>
>
> Martin
>
>
>
>


Re: bayes_toks location when running as a service

Posted by Martin Gregorie <ma...@gregorie.org>.
On Sat, 2019-11-23 at 13:07 -0600, Jerry Malcolm wrote:
> Bob & John.... Thanks so much for the info.  But as if I wasn't dazed
> & confused enough already, I have discovered a new variable to the
> whole thing.  I have set up a couple of sandbox EC2 instances just to
> play.  I didn't realize it at first, but one is AWS Linux 1 and the
> other is AWS Linux 2.  And the whole startup file structure is
> different between the two.  The Linux 1 env does indeed have
> /etc/init.d/spamassassin.  But I don't see anything that looks like
> it's setting a user to 'spamd'.  In 
> the Linux 2 env, I have:
> 
> /usr/lib/systemd/system/spamassassin.service that starts
> /usr/bin/spamd 
> using options file /etc/sysconfig/spamassassin
> 
That tells is that the AWS Linux 1 system uses the good old sysVinit
system for starting/stopping and controlling system services - its
virtually unchanged since it first appeared in Unix SVr4, while the AWS
Linux 2 system is using the newer Systemd in its place. 

Systemd appeared in  RedHat Linux's Fedora (their free distro) a few
years back when Fedora 20 was released and is a totally different beast.
Its gradually replaced SysvInit in all the main distros since then, so
now there only a few sysVinit based Linuxes and these are used by the
remaining systemd holdouts.

There's a decent documentation set for systemd here:
https://www.freedesktop.org/wiki/Software/systemd/


Martin



Re: bayes_toks location when running as a service

Posted by Jerry Malcolm <te...@malcolms.com>.
On 11/23/2019 3:00 PM, Bob D wrote:
> On 11/23/19 1:07 PM, Jerry Malcolm wrote:
>>
>> Bob & John.... Thanks so much for the info.  But as if I wasn't dazed 
>> & confused enough already, I have discovered a new variable to the 
>> whole thing.  I have set up a couple of sandbox EC2 instances just to 
>> play.  I didn't realize it at first, but one is AWS Linux 1 and the 
>> other is AWS Linux 2. And the whole startup file structure is 
>> different between the two.  The Linux 1 env does indeed have 
>> /etc/init.d/spamassassin.  But I don't see anything that looks like 
>> it's setting a user to 'spamd'.  In the Linux 2 env, I have:
>>
> That script should contain setting near the top such as:
> 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"
>
> The "NAME" setting above is the run user.
This is my entire /usr/lib/systemd/system/spamassassin.service file (on 
Linux 2):

[Unit]
Description=Spamassassin daemon
After=syslog.target network.target

[Service]
Type=forking
PIDFile=/var/run/spamd.pid
EnvironmentFile=-/etc/sysconfig/spamassassin
ExecStartPre=-/sbin/portrelease spamd
ExecStart=/usr/bin/spamd --pidfile /var/run/spamd.pid $SPAMDOPTIONS
StandardOutput=syslog
StandardError=syslog
Restart=always

[Install]
WantedBy=multi-user.target

>
> You might of missed the spamd user, try:   grep spamd /etc/passwd
I have already created a spamd user.  But the create was successful.  So 
I assume it did not previously exist.  Linux 101 question... what is the 
command to show running processes along with the user they are running 
as?  I tried googling that.  But apparently I'm not asking the question 
right. Couldn't find anything.  I may just create a new EC2 instance 
from scratch and check again what happens by default.
>
>> /usr/lib/systemd/system/spamassassin.service that starts 
>> /usr/bin/spamd using options file /etc/sysconfig/spamassassin
>>
>> I read elsewhere that a "User=" parm can be added to a .service 
>> file.  But the one I have has nothing related to user.  The 
>> usr/bin/spamd file is nearly 4000 lines.  It's setting the folders, 
>> logging, etc.  So it appears to be the main script.  But from my 
>> understanding, the user would already be set prior to this script 
>> being called.
>>
>> Kris D suggested I add "-u spamd" to the options file.  But I looked 
>> in /etc/passwd and there is no spamd user.  There is no user defined 
>> that even remotely resembles an id that SA would have created.  (This 
>> is all on the Linux 2 instance, haven't checked the Linux 1 instance 
>> yet).
>>
>> I can hack around and add a spamd user and add the parameters to make 
>> spamd run as that id and then check the logs to see where SA is 
>> looking now for bayes_*.  But that seems to be a fairly wide 
>> departure from an out-of-the-box experience.  Does this seem right?  
>> I always very cautious before claiming "bug". But it is possible some 
>> critical items were left out of the AWS Linux 2 install package for 
>> SA?  Should I go ahead and add the spamd user?
>>
> You should not have to add the user.
>>
>> Thx again.
>>
>> Jerry
>>
>>
>

Re: bayes_toks location when running as a service

Posted by Bob D <bo...@inter-control.com>.
On 11/23/19 1:07 PM, Jerry Malcolm wrote:
>
> Bob & John.... Thanks so much for the info.  But as if I wasn't dazed 
> & confused enough already, I have discovered a new variable to the 
> whole thing.  I have set up a couple of sandbox EC2 instances just to 
> play.  I didn't realize it at first, but one is AWS Linux 1 and the 
> other is AWS Linux 2.  And the whole startup file structure is 
> different between the two. The Linux 1 env does indeed have 
> /etc/init.d/spamassassin.  But I don't see anything that looks like 
> it's setting a user to 'spamd'.  In the Linux 2 env, I have:
>
That script should contain setting near the top such as:
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"

The "NAME" setting above is the run user.

You might of missed the spamd user, try:   grep spamd /etc/passwd

> /usr/lib/systemd/system/spamassassin.service that starts 
> /usr/bin/spamd using options file /etc/sysconfig/spamassassin
>
> I read elsewhere that a "User=" parm can be added to a .service file.  
> But the one I have has nothing related to user.  The usr/bin/spamd 
> file is nearly 4000 lines.  It's setting the folders, logging, etc.  
> So it appears to be the main script.  But from my understanding, the 
> user would already be set prior to this script being called.
>
> Kris D suggested I add "-u spamd" to the options file.  But I looked 
> in /etc/passwd and there is no spamd user.  There is no user defined 
> that even remotely resembles an id that SA would have created.  (This 
> is all on the Linux 2 instance, haven't checked the Linux 1 instance yet).
>
> I can hack around and add a spamd user and add the parameters to make 
> spamd run as that id and then check the logs to see where SA is 
> looking now for bayes_*.  But that seems to be a fairly wide departure 
> from an out-of-the-box experience.  Does this seem right?  I always 
> very cautious before claiming "bug".  But it is possible some critical 
> items were left out of the AWS Linux 2 install package for SA?  Should 
> I go ahead and add the spamd user?
>
You should not have to add the user.
>
> Thx again.
>
> Jerry
>
>


Re: Resolution: bayes_toks location when running as a service

Posted by Bob D <bo...@inter-control.com>.

On 11/23/19 2:50 PM, Jerry Malcolm wrote:
>
> Ok, I made the following changes and got it to finally work (on Linux 2):
>
> 1) I created a user named spamd
>
> 2) I added  -u spamd  to  SPAMDOPTIONS in /etc/sysconfig/spamassassin  
> --- after doing this, no change... log said SA was still looking in 
> the random /tmp file for bayes_*.
>
> 3) I added bayes_path /home/spamd/bayes/bayes to 
> /etc/mail/spamassassin/local.cf
>
> 4) I moved my bayes_toks, bayes_seen, bayes_journal to 
> /home/spamd/bayes/ folder
>
> 5) After starting spamd service, maillog (finally) says it's finding 
> the bayes_* files in the /home/spamd/... folder.
>
> So this is the 'what', but definitely not the 'why'. Observations....
>
>     -- After adding the bayes_path  to local.cf but BEFORE moving the 
> bayes_* files into that folder, the log indeed showed that it was 
> looking in that folder.  However not finding any files there, it then 
> tried looking in the /tmp random folder. But after I moved the files 
> into that folder and restarted, spamd was now happy with the specified 
> folder and did NOT look in the /tmp random folder.  So it appears that 
> the /tmp random folder is the last-ditch effort to find some files 
> (not sure why it would expect anything there... but so be it).  
> However, the optional bayes_path parm is somehow not so optional in 
> spamd, at least in my environment.  It is being set to the user home 
> folder when running spamassassin from CLI.  But it is NOT being set to 
> anything when running spamd.
>
The script: /usr/lib/systemd/system/spamassassin.service should have a 
"NAME" setting in the beginning. This is the run user.

>     -- Second observation, I still am not sure what user spamd was 
> running under by default when not specified.  So in order to guarantee 
> that the folder I did pick for bayes_path was accessible for whatever 
> user spamd was running under, I think it was necessary to add the 
> 'spamd' user and force spamd to run as user 'spamd'.
>
The default installed user should be "spamd".

> Are my assumptions reasonably close?  Is it possible that this process 
> could be made a bit easier for 'stupid idiots' like me? :-)
>
What's the saying about assume ?   #;)
Linux easy ??  "Tosten en Strudel ? Ha Ha Ha Ha"
>
> Thanks so much.  I could NOT have done without your help.
>
> Jerry
>
> On 11/23/2019 1:56 PM, Jerry Malcolm wrote:
>> All righty...
>>
>> On 11/23/2019 1:37 PM, Bob D wrote:
>>> Jerry,
>>> Let's back up a bit.
>>> Let us see your distro via the command      lsb_release -a
>>         bash: lsb_release: command not found  -- is that in a certain 
>> folder I need to cd to?
>>> Also the version via   uname -r
>>         4.14.154-128.181.amzn2.x86_64
>>> Additionally, how did you install spamassassin please ?
>>         sudo yum install spamassassin  (just responded 'y' when 
>> asked... nothing else)
>>>
>>>


Resolution: bayes_toks location when running as a service

Posted by Jerry Malcolm <te...@malcolms.com>.
Ok, I made the following changes and got it to finally work (on Linux 2):

1) I created a user named spamd

2) I added  -u spamd  to  SPAMDOPTIONS in /etc/sysconfig/spamassassin  
--- after doing this, no change... log said SA was still looking in the 
random /tmp file for bayes_*.

3) I added bayes_path /home/spamd/bayes/bayes to 
/etc/mail/spamassassin/local.cf

4) I moved my bayes_toks, bayes_seen, bayes_journal to 
/home/spamd/bayes/ folder

5) After starting spamd service, maillog (finally) says it's finding the 
bayes_* files in the /home/spamd/... folder.

So this is the 'what', but definitely not the 'why'. Observations....

     -- After adding the bayes_path  to local.cf but BEFORE moving the 
bayes_* files into that folder, the log indeed showed that it was 
looking in that folder.  However not finding any files there, it then 
tried looking in the /tmp random folder.  But after I moved the files 
into that folder and restarted, spamd was now happy with the specified 
folder and did NOT look in the /tmp random folder.  So it appears that 
the /tmp random folder is the last-ditch effort to find some files (not 
sure why it would expect anything there... but so be it).  However, the 
optional bayes_path parm is somehow not so optional in spamd, at least 
in my environment.  It is being set to the user home folder when running 
spamassassin from CLI.  But it is NOT being set to anything when running 
spamd.

     -- Second observation, I still am not sure what user spamd was 
running under by default when not specified.  So in order to guarantee 
that the folder I did pick for bayes_path was accessible for whatever 
user spamd was running under, I think it was necessary to add the 
'spamd' user and force spamd to run as user 'spamd'.

Are my assumptions reasonably close?  Is it possible that this process 
could be made a bit easier for 'stupid idiots' like me? :-)

Thanks so much.  I could NOT have done without your help.

Jerry

On 11/23/2019 1:56 PM, Jerry Malcolm wrote:
> All righty...
>
> On 11/23/2019 1:37 PM, Bob D wrote:
>> Jerry,
>> Let's back up a bit.
>> Let us see your distro via the command      lsb_release -a
>         bash: lsb_release: command not found  -- is that in a certain 
> folder I need to cd to?
>> Also the version via   uname -r
>         4.14.154-128.181.amzn2.x86_64
>> Additionally, how did you install spamassassin please ?
>         sudo yum install spamassassin  (just responded 'y' when 
> asked... nothing else)
>>
>>

Re: bayes_toks location when running as a service

Posted by Jerry Malcolm <te...@malcolms.com>.
All righty...

On 11/23/2019 1:37 PM, Bob D wrote:
> Jerry,
> Let's back up a bit.
> Let us see your distro via the command      lsb_release -a
         bash: lsb_release: command not found  -- is that in a certain 
folder I need to cd to?
> Also the version via   uname -r
         4.14.154-128.181.amzn2.x86_64
> Additionally, how did you install spamassassin please ?
         sudo yum install spamassassin  (just responded 'y' when 
asked... nothing else)
>
>

Re: bayes_toks location when running as a service

Posted by Bob D <bo...@inter-control.com>.
Jerry,
Let's back up a bit.
Let us see your distro via the command      lsb_release -a
Also the version via   uname -r
Additionally, how did you install spamassassin please ?


On 11/23/19 1:07 PM, Jerry Malcolm wrote:
>
> Bob & John.... Thanks so much for the info.  But as if I wasn't dazed 
> & confused enough already, I have discovered a new variable to the 
> whole thing.  I have set up a couple of sandbox EC2 instances just to 
> play.  I didn't realize it at first, but one is AWS Linux 1 and the 
> other is AWS Linux 2.  And the whole startup file structure is 
> different between the two. The Linux 1 env does indeed have 
> /etc/init.d/spamassassin.  But I don't see anything that looks like 
> it's setting a user to 'spamd'.  In the Linux 2 env, I have:
>
> /usr/lib/systemd/system/spamassassin.service that starts 
> /usr/bin/spamd using options file /etc/sysconfig/spamassassin
>
> I read elsewhere that a "User=" parm can be added to a .service file.  
> But the one I have has nothing related to user.  The usr/bin/spamd 
> file is nearly 4000 lines.  It's setting the folders, logging, etc.  
> So it appears to be the main script.  But from my understanding, the 
> user would already be set prior to this script being called.
>
> Kris D suggested I add "-u spamd" to the options file.  But I looked 
> in /etc/passwd and there is no spamd user.  There is no user defined 
> that even remotely resembles an id that SA would have created.  (This 
> is all on the Linux 2 instance, haven't checked the Linux 1 instance yet).
>
> I can hack around and add a spamd user and add the parameters to make 
> spamd run as that id and then check the logs to see where SA is 
> looking now for bayes_*.  But that seems to be a fairly wide departure 
> from an out-of-the-box experience.  Does this seem right?  I always 
> very cautious before claiming "bug".  But it is possible some critical 
> items were left out of the AWS Linux 2 install package for SA?  Should 
> I go ahead and add the spamd user?
>
> Thx again.
>
> Jerry
>
>


Re: bayes_toks location when running as a service

Posted by RW <rw...@googlemail.com>.
On Sat, 23 Nov 2019 15:41:44 -0600
Jerry Malcolm wrote:

> On 11/23/2019 3:24 PM, RW wrote:
> > On Sat, 23 Nov 2019 13:07:02 -0600

> > In the latter case you start spamd with '-u spamd'. It typically
> > starts as root and drops privileges after binding to the default
> > port. If you don't need that low port you can start it directly as
> > the unprivileged user, but you still need '-u spamd'.  

> I'm not sure what you mean by 'need that low port'.  I was just using 
> the default port 783.  Are you saying that if I add -u spamd I am not 
> going to be able to use that port? 

No, I saying that if you make it start directly as the user spamd,
rather than let it start as root and drop to spamd, it wont be able to
to use a port under 1024. 


>  I can change the 
> port if necessary.

You don't need to do that.




Re: bayes_toks location when running as a service

Posted by Jerry Malcolm <te...@malcolms.com>.
On 11/23/2019 3:24 PM, RW wrote:
> On Sat, 23 Nov 2019 13:07:02 -0600
> Jerry Malcolm wrote:
>
>> Bob & John.... Thanks so much for the info.  But as if I wasn't dazed
>> & confused enough already, I have discovered a new variable to the
>> whole thing.  I have set up a couple of sandbox EC2 instances just to
>> play.  I didn't realize it at first, but one is AWS Linux 1 and the
>> other is AWS Linux 2.  And the whole startup file structure is
>> different between the two.  The Linux 1 env does indeed have
>> /etc/init.d/spamassassin.  But I don't see anything that looks like
>> it's setting a user to 'spamd'.  In the Linux 2 env, I have:
>>
>> /usr/lib/systemd/system/spamassassin.service that starts
>> /usr/bin/spamd using options file /etc/sysconfig/spamassassin
>>
>> I read elsewhere that a "User=" parm can be added to a .service file.
>> But the one I have has nothing related to user.  The usr/bin/spamd
>> file is nearly 4000 lines.  It's setting the folders, logging, etc.
>> So it appears to be the main script.  But from my understanding, the
>> user would already be set prior to this script being called.
>>
>> Kris D suggested I add "-u spamd" to the options file.
>
> There are two ways to run spamd, with unix users, and with a single
> unprivileged (unix) user.
>
> With the former spamd starts as root, without ( -u spamd), and the
> child processes drop privileges to the user running spamc, this enables
> spamc to behave like an ordinary unix command storing it's user config
> and data under ~/.spamassassin. Unless you are running a login server
> you probably don't want to do this.
>
> In the latter case you start spamd with '-u spamd'. It typically
> starts as root and drops privileges after binding to the default port.
> If you don't need that low port you can start it directly as the
> unprivileged user, but you still need '-u spamd'.
I'm not sure what you mean by 'need that low port'.  I was just using 
the default port 783.  Are you saying that if I add -u spamd I am not 
going to be able to use that port?  Not a big deal.  I can change the 
port if necessary.  But how high a port number do I need?
>
> When you run with '-u spamd' everything is global by default (you can
> have per mail account databases and config if you set-up virtual
> users). If you have a home directory for the spamd user, you do not
> need to set bayes_path, and you should ignore the wiki link, it's just a
> kludge to have a global bayes with the unix user setup.
Thank you so much for the additional education.  This has been very 
helpful for me.
>
>
>
>
>
>

Re: bayes_toks location when running as a service

Posted by RW <rw...@googlemail.com>.
On Sat, 23 Nov 2019 13:07:02 -0600
Jerry Malcolm wrote:

> Bob & John.... Thanks so much for the info.  But as if I wasn't dazed
> & confused enough already, I have discovered a new variable to the
> whole thing.  I have set up a couple of sandbox EC2 instances just to
> play.  I didn't realize it at first, but one is AWS Linux 1 and the
> other is AWS Linux 2.  And the whole startup file structure is
> different between the two.  The Linux 1 env does indeed have
> /etc/init.d/spamassassin.  But I don't see anything that looks like
> it's setting a user to 'spamd'.  In the Linux 2 env, I have:
> 
> /usr/lib/systemd/system/spamassassin.service that starts
> /usr/bin/spamd using options file /etc/sysconfig/spamassassin
> 
> I read elsewhere that a "User=" parm can be added to a .service file.
> But the one I have has nothing related to user.  The usr/bin/spamd
> file is nearly 4000 lines.  It's setting the folders, logging, etc.
> So it appears to be the main script.  But from my understanding, the
> user would already be set prior to this script being called.
> 
> Kris D suggested I add "-u spamd" to the options file.  


There are two ways to run spamd, with unix users, and with a single
unprivileged (unix) user. 

With the former spamd starts as root, without ( -u spamd), and the
child processes drop privileges to the user running spamc, this enables
spamc to behave like an ordinary unix command storing it's user config
and data under ~/.spamassassin. Unless you are running a login server
you probably don't want to do this.

In the latter case you start spamd with '-u spamd'. It typically
starts as root and drops privileges after binding to the default port.
If you don't need that low port you can start it directly as the
unprivileged user, but you still need '-u spamd'.

When you run with '-u spamd' everything is global by default (you can
have per mail account databases and config if you set-up virtual
users). If you have a home directory for the spamd user, you do not
need to set bayes_path, and you should ignore the wiki link, it's just a
kludge to have a global bayes with the unix user setup.







Re: bayes_toks location when running as a service

Posted by Jerry Malcolm <te...@malcolms.com>.
Bob & John.... Thanks so much for the info.  But as if I wasn't dazed & 
confused enough already, I have discovered a new variable to the whole 
thing.  I have set up a couple of sandbox EC2 instances just to play.  I 
didn't realize it at first, but one is AWS Linux 1 and the other is AWS 
Linux 2.  And the whole startup file structure is different between the 
two.  The Linux 1 env does indeed have /etc/init.d/spamassassin.  But I 
don't see anything that looks like it's setting a user to 'spamd'.  In 
the Linux 2 env, I have:

/usr/lib/systemd/system/spamassassin.service that starts /usr/bin/spamd 
using options file /etc/sysconfig/spamassassin

I read elsewhere that a "User=" parm can be added to a .service file.  
But the one I have has nothing related to user.  The usr/bin/spamd file 
is nearly 4000 lines.  It's setting the folders, logging, etc. So it 
appears to be the main script.  But from my understanding, the user 
would already be set prior to this script being called.

Kris D suggested I add "-u spamd" to the options file.  But I looked in 
/etc/passwd and there is no spamd user.  There is no user defined that 
even remotely resembles an id that SA would have created.  (This is all 
on the Linux 2 instance, haven't checked the Linux 1 instance yet).

I can hack around and add a spamd user and add the parameters to make 
spamd run as that id and then check the logs to see where SA is looking 
now for bayes_*.  But that seems to be a fairly wide departure from an 
out-of-the-box experience.  Does this seem right?  I always very 
cautious before claiming "bug".  But it is possible some critical items 
were left out of the AWS Linux 2 install package for SA?  Should I go 
ahead and add the spamd user?

Thx again.

Jerry



Re: bayes_toks location when running as a service

Posted by Bob D <bo...@inter-control.com>.
Hello Jerry,
In a nut-shell;
It generally takes root equivalent to initiate system services. Hence 
the su.
The startup of the individual service usually handles changing the 
effective user to some definition defined in the individual setup files 
of the service providing it was written to allow changes.
Look for the start script in the /etc/init.d/ folder it is called 
spamassassin. (full path= /etc/init.d/spamassassin) But make no changes 
here!
You will see there that the spamassassin daemon is called spamd and is 
daemonized and run under the user spamd. (the user should of been 
created upon installation)
In the case of Spamassassin, the general configuration files are 
typically in the /etc/spamassassin folder depending on distro. You 
should limit your changes to this folder.
As has been stated, all .cf files here are examined.
Specifically, the /etc/spamassassin/local.cf file which will contain 
setup information on bayes as well as other things.
The bayes section should indicate (and allow) setting of the path to the 
db among other things.
Hope this helps with your main question.
Also if you are running Amavis, then Amavis calls spamassassin I think 
via spamc (the client to spamd the daemon) and does so using the user 
amavis.
Amavis runs tend to run seperately from the normal spamassassin run 
structure and can be difficult at best to follow/troubleshoot.
Clear as mud ?
Regards
Bob

On 11/23/19 11:09 AM, Jerry Malcolm wrote:
> Meanwhile, back at the ranch.... I still have the one outstanding 
> question from before the 'interruption'....
>
> I know it may be the unpardonable sin according to some to ask a 
> question without having a PhD in Linux.  But after 30+ years in 
> Windows and (yes) OS/2 design and  development for IBM, I have not had 
> much Linux experience. Forgive me.  My assignments at IBM were not in 
> the AIX/*un*x arenas.  I've learned a lot about Linux in the 4 months 
> since moving to my new AWS environment.  But I'm still learning.  I 
> understand about running as 'ec2-user' (the automatic default id that 
> AWS gives you in each ec2 instance).  I also understand 'sudo su' 
> which causes CLI commands to run as root.  But it gets murky when 
> running services.  I have to use 'sudo' to start the spamassassin 
> service.  But does the service itself really run as root?
>
> My one single question is... where does SA expect to find bayes_toks 
> when running the spamd service 'site-wide-only; no per-user stuff'
>
> -- When running from the command line as a normal user, the SA log 
> says it is looking for bayes_* in /user/ec-2user/.spamassassin. Ok, 
> that makes sense.
>
> -- When running from the command after "sudo su" (Horrors!!! how I can 
> ever be forgiven????) the SA log says it is looking for bayes_* in 
> /root/.spamassassin.  Ok, I can understand that as well.
>
> -- But when I start up spamd as a service, the log says it now wants 
> to find bayes_* in  /tmp/spamd-4551-init/.spamassassin. (and the 
> 4-digit number changes each time I restart the service.
>
> I have no problem putting bayes_toks wherever SA wants it to be for 
> running as a service.  But I don't think a random named folder in /tmp 
> is the right place.
>
> What is causing SA to change from a fixed folder to a random /tmp 
> folder for bayes_* when running spamd as a service?  What do I need to 
> do to make it look in a fixed folder? And what folder would that be 
> for 'site-wide-only' use?  (ok... that's 3 questions.... :-)  ).
>
> Thanks so much.
>
> Jerry
>
>
>


Re: bayes_toks location when running as a service

Posted by John Hardin <jh...@impsec.org>.
On Sat, 23 Nov 2019, Jerry Malcolm wrote:

> -- But when I start up spamd as a service, the log says it now wants to find 
> bayes_* in  /tmp/spamd-4551-init/.spamassassin. (and the 4-digit number 
> changes each time I restart the service.

What user is the service running spamd as?

What is that user's home directory?

Does the service startup script make any changes to the config files or 
override the config on the spamd command line it runs?

Changing the folder on every startup implies that there's no way you'll 
ever be able to train bayes... that seems *very* strange...

-- 
  John Hardin KA7OHZ                    http://www.impsec.org/~jhardin/
  jhardin@impsec.org    FALaholic #11174     pgpk -a jhardin@impsec.org
  key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C  AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
   When fascism comes to America, it will be wrapped in
   "Diversity" and demanding "Safe Spaces."             -- Mona Charen
-----------------------------------------------------------------------
  968 days since the first commercial re-flight of an orbital booster (SpaceX)

bayes_toks location when running as a service

Posted by Jerry Malcolm <te...@malcolms.com>.
Meanwhile, back at the ranch.... I still have the one outstanding 
question from before the 'interruption'....

I know it may be the unpardonable sin according to some to ask a 
question without having a PhD in Linux.  But after 30+ years in Windows 
and (yes) OS/2 design and  development for IBM, I have not had much 
Linux experience. Forgive me.  My assignments at IBM were not in the 
AIX/*un*x arenas.  I've learned a lot about Linux in the 4 months since 
moving to my new AWS environment.  But I'm still learning.  I understand 
about running as 'ec2-user' (the automatic default id that AWS gives you 
in each ec2 instance).  I also understand 'sudo su' which causes CLI 
commands to run as root.  But it gets murky when running services.  I 
have to use 'sudo' to start the spamassassin service.  But does the 
service itself really run as root?

My one single question is... where does SA expect to find bayes_toks 
when running the spamd service 'site-wide-only; no per-user stuff'

-- When running from the command line as a normal user, the SA log says 
it is looking for bayes_* in /user/ec-2user/.spamassassin.  Ok, that 
makes sense.

-- When running from the command after "sudo su" (Horrors!!! how I can 
ever be forgiven????) the SA log says it is looking for bayes_* in 
/root/.spamassassin.  Ok, I can understand that as well.

-- But when I start up spamd as a service, the log says it now wants to 
find bayes_* in  /tmp/spamd-4551-init/.spamassassin. (and the 4-digit 
number changes each time I restart the service.

I have no problem putting bayes_toks wherever SA wants it to be for 
running as a service.  But I don't think a random named folder in /tmp 
is the right place.

What is causing SA to change from a fixed folder to a random /tmp folder 
for bayes_* when running spamd as a service?  What do I need to do to 
make it look in a fixed folder? And what folder would that be for 
'site-wide-only' use?  (ok... that's 3 questions.... :-)  ).

Thanks so much.

Jerry


Re: Where is SA getting config info?

Posted by Bob D <bo...@inter-control.com>.
This may help,
https://cwiki.apache.org/confluence/display/spamassassin/SiteWideBayesSetup


On 11/23/19 10:25 AM, Jerry Malcolm wrote:
> Thank you for the information.  I apologize for taking the bait. It 
> just totally blindsided me that anyone here would initiate such a 
> vicious personal attack.  Feel free to delete the recent chain of 
> responses from the users group.
>
> Jerry
>
> On 11/22/2019 8:48 PM, Ralph Seichter wrote:
>> * Jerry Malcolm:
>>
>>> Why don't you just consider not "helping" anybody else here.
>> Reindl Harald has been evicted, for good reason, from many mailing lists
>> I subscribe to. I still recommend blocking him locally via killfiles or
>> similar methods. He's not worth paying attention to.
>>
>> -Ralph
>
>


Re: Where is SA getting config info?

Posted by Jerry Malcolm <te...@malcolms.com>.
Thank you for the information.  I apologize for taking the bait. It just 
totally blindsided me that anyone here would initiate such a vicious 
personal attack.  Feel free to delete the recent chain of responses from 
the users group.

Jerry

On 11/22/2019 8:48 PM, Ralph Seichter wrote:
> * Jerry Malcolm:
>
>> Why don't you just consider not "helping" anybody else here.
> Reindl Harald has been evicted, for good reason, from many mailing lists
> I subscribe to. I still recommend blocking him locally via killfiles or
> similar methods. He's not worth paying attention to.
>
> -Ralph

Re: Where is SA getting config info?

Posted by Ralph Seichter <ab...@monksofcool.net>.
* Jerry Malcolm:

> Why don't you just consider not "helping" anybody else here.

Reindl Harald has been evicted, for good reason, from many mailing lists
I subscribe to. I still recommend blocking him locally via killfiles or
similar methods. He's not worth paying attention to.

-Ralph

Re: Where is SA getting config info?

Posted by John Hardin <jh...@impsec.org>.
On Fri, 22 Nov 2019, Rick Macdougall wrote:

> For the good of your blood pressure, just ignore h.reindl@thelounge.net
>
> I've plonked every thing from him into /dev/null so long ago I can't remember 
> when I did it.
>
> Why he's still allowed to post here is beyond me.

He's not. But he does still read the list and replies directly, and when 
*that* is replied to it often ends up on-list, much to our recurring 
dismay.

>
> Regards,
>
> Rick

-- 
  John Hardin KA7OHZ                    http://www.impsec.org/~jhardin/
  jhardin@impsec.org    FALaholic #11174     pgpk -a jhardin@impsec.org
  key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C  AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
   When fascism comes to America, it will be wrapped in
   "Diversity" and demanding "Safe Spaces."             -- Mona Charen
-----------------------------------------------------------------------
  968 days since the first commercial re-flight of an orbital booster (SpaceX)

Re: Where is SA getting config info?

Posted by Bill Cole <sa...@billmail.scconsult.com>.
On 22 Nov 2019, at 20:26, Rick Macdougall wrote:

> Hi,
>
> For the good of your blood pressure, just ignore 
> h.reindl@thelounge.net
>
> I've plonked every thing from him into /dev/null so long ago I can't 
> remember when I did it.
>
> Why he's still allowed to post here is beyond me.

He isn't. Note the lack of any of his messages at 
https://mail-archives.apache.org/mod_mbox/spamassassin-users/201911.mbox/date.

There is no way to prevent anyone from reading messages posted to this 
mailing list or to prevent them from responding to list messages by 
replying directly to list members.

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

Re: Where is SA getting config info?

Posted by Rick Macdougall <ri...@ummm-beer.com>.
Hi,

For the good of your blood pressure, just ignore h.reindl@thelounge.net

I've plonked every thing from him into /dev/null so long ago I can't 
remember when I did it.

Why he's still allowed to post here is beyond me.

Regards,

Rick

On 2019-11-22 7:20 p.m., Jerry Malcolm wrote:
> Then I guess the SpamAssassin team will give you an award for insulting 
> their users who are simply have a question.  That's a good way to keep 
> people from bothering you by asking questions on the users group.  You 
> obviously don't know it.  But most people don't like being called a 
> stupid idiot just because they aren't as smart as you think you are.
> 
> I apologize for interrupting your life with such a stupid question.  I 
> am not worthy of being on this forum since I'm obviously too stupid. Why 
> don't you just consider not "helping" anybody else here.
> 
> 
> On 11/22/2019 6:10 PM, Reindl Harald wrote:
>>
>> Am 23.11.19 um 01:03 schrieb Jerry Malcolm:
>>> What a wonderful way to be treated by a know-it-all arrogant asshole to
>>> someone who has a problem with your stupid program and simply wants
>>> answers.
>> it's NOT my program
>>
>>> I DIDN'T DO A THING TO SPECIFY ANYTHING ABOUT ROOT.  THAT IS WHAT
>>> APPEARS IN THE LOGS RIGHT OUT OF THE BOX.
>> you obvisouly did run sa-commands as root god damned
>>
>> do not execture any commadn as root which does not need root
>> permissions, it's that easy and has *nothing* to do with spamassassin
>>
>> [root@mail-gw:~]$ cat /etc/passwd| grep milter
>> clamilt:x:190:189:Clamav Milter
>> user:/var/run/clamav-milter:/usr/sbin/nologin
>> sa-milt:x:189:188:SpamAssassin 
>> Milter:/var/lib/spamass-milter:/usr/bin/bash
>> [root@mail-gw:~]$ su - sa-milt
>> [sa-milt@mail-gw:~]$
>>
>> and *only now* i run *any* SA related command, from day one many years 
>> ago
>>
>> [root@mail-gw:~]$ cat /etc/systemd/system/spamassassin.service
>> [Unit]
>> Description=Spamassassin Inbound Daemon
>> Wants=sa-update.timer
>>
>> [Service]
>> EnvironmentFile=-/etc/sysconfig/tsx
>> Environment="TMPDIR=/tmp"
>> PermissionsStartOnly=true
>> ExecStartPre=/usr/bin/chown -R sa-cleanup:root /var/lib/spamassassin/
>> ExecStartPre=/usr/bin/find /var/lib/spamassassin/ -type d -exec
>> /bin/chmod 0755 "{}" \;
>> ExecStartPre=/usr/bin/find /var/lib/spamassassin/ -type f -exec
>> /bin/chmod 0644 "{}" \;
>> ExecStart=/usr/bin/spamd --max-children=5 --round-robin
>> --max-conn-per-child=25 --socketpath=/run/spamassassin/spamassassin.sock
>> --socketmode=0666
>> ExecReload=/usr/bin/kill -HUP $MAINPID
>> Environment="LANG=C.UTF-8"
>> *User=sa-milt*
>> *Group=sa-milt*
>> RuntimeDirectory=spamassassin
>> RuntimeDirectoryMode=0775
>> StandardOutput=null
>> StandardError=null
>> SyslogFacility=mail
>> Restart=always
>> RestartSec=1
>> Nice=4
>>
>> CapabilityBoundingSet=CAP_KILL
>> MemoryDenyWriteExecute=yes
>> NoNewPrivileges=yes
>> PrivateDevices=yes
>> PrivateTmp=yes
>> ProtectControlGroups=yes
>> ProtectKernelModules=yes
>> ProtectKernelTunables=yes
>> RestrictRealtime=yes
>>
>>> What part of "OUT OF THE BOX UNMODIFIED are you having trouble with????
>>> I guess I'm just a stupid idiot for thinking anything you'd write would
>>> work out of the box.
>>>
>>> On 11/22/2019 5:56 PM, Reindl Harald wrote:
>>>> Am 23.11.19 um 00:54 schrieb Jerry Malcolm:
>>>>> I don't appreciate you implying I'm a stupid idiot.  That and every 
>>>>> bit
>>>>> of your language has NO place on this forum, especially your reference
>>>>> to my Lord and Savior!!!!
>>>>>
>>>>> I had NOTHING to do with setting that folder, no matter how STUPID you
>>>>> think I am.  That's the folder that appeared in the log file when I 
>>>>> ran
>>>>> it out of the box.  Why don't you read the full thread before 
>>>>> INSULTING
>>>>> people.
>>>> /root/ does not appear out of the blue
>>>>
>>>>>>> When running the same SA as a service,
>>>>>>> it's NOT looking for bayes in
>>>>>>> /root/.spamassassin
>>>> you *are* an idiot when you expect to run a service as *root* 
>>>> looking in
>>>> /root/ - common sense
>>>>
>>>>> On 11/22/2019 5:17 PM, Reindl Harald wrote:
>>>>>> Am 22.11.19 um 23:06 schrieb Jerry Malcolm:
>>>>>>> Well,  I thought I finally had everything resolved.  When I run
>>>>>>> spamassassin -D --lint I get the lines:
>>>>>>>
>>>>>>> Nov 22 21:57:57.954 [13813] dbg: bayes: tie-ing to DB file R/O
>>>>>>> /root/.spamassassin/bayes_toks
>>>>>>> Nov 22 21:57:57.954 [13813] dbg: bayes: tie-ing to DB file R/O
>>>>>>> /root/.spamassassin/bayes_seen
>>>>>>> Nov 22 21:57:57.955 [13813] dbg: bayes: found bayes db version 3
>>>>>>>
>>>>>>> So, I'm ready to start it up as a daemon and start using it... I
>>>>>>> checked
>>>>>>> /var/log/maillog and see this instead:
>>>>>>>
>>>>>>> Nov 22 21:58:21 ip-172-31-47-84 spamd[13780]: bayes: no dbs present,
>>>>>>> cannot tie DB R/O: /tmp/spamd-13780-init/.spamassassin/bayes_toks
>>>>>>>
>>>>>>> When running the same SA as a service, it's NOT looking for bayes in
>>>>>>> /root/.spamassassin
>>>>>> jesus christ why should a service typically not running as root 
>>>>>> look in
>>>>>> roots home directory? why should it even can access it and if it can
>>>>>> which idiot ruined your permissions?
>>>>>>
>>>>>> why the hell are you doing *anything* as root at all?
>>>>>>
>>>>>> * train bays as the user spamd is running
>>>>>> * locate bayes in the homedirectory of that user
>>>>>> * done


Re: Where is SA getting config info?

Posted by Jerry Malcolm <te...@malcolms.com>.
Then I guess the SpamAssassin team will give you an award for insulting 
their users who are simply have a question.  That's a good way to keep 
people from bothering you by asking questions on the users group.  You 
obviously don't know it.  But most people don't like being called a 
stupid idiot just because they aren't as smart as you think you are.

I apologize for interrupting your life with such a stupid question.  I 
am not worthy of being on this forum since I'm obviously too stupid.  
Why don't you just consider not "helping" anybody else here.


On 11/22/2019 6:10 PM, Reindl Harald wrote:
>
> Am 23.11.19 um 01:03 schrieb Jerry Malcolm:
>> What a wonderful way to be treated by a know-it-all arrogant asshole to
>> someone who has a problem with your stupid program and simply wants
>> answers.
> it's NOT my program
>
>> I DIDN'T DO A THING TO SPECIFY ANYTHING ABOUT ROOT.  THAT IS WHAT
>> APPEARS IN THE LOGS RIGHT OUT OF THE BOX.
> you obvisouly did run sa-commands as root god damned
>
> do not execture any commadn as root which does not need root
> permissions, it's that easy and has *nothing* to do with spamassassin
>
> [root@mail-gw:~]$ cat /etc/passwd| grep milter
> clamilt:x:190:189:Clamav Milter
> user:/var/run/clamav-milter:/usr/sbin/nologin
> sa-milt:x:189:188:SpamAssassin Milter:/var/lib/spamass-milter:/usr/bin/bash
> [root@mail-gw:~]$ su - sa-milt
> [sa-milt@mail-gw:~]$
>
> and *only now* i run *any* SA related command, from day one many years ago
>
> [root@mail-gw:~]$ cat /etc/systemd/system/spamassassin.service
> [Unit]
> Description=Spamassassin Inbound Daemon
> Wants=sa-update.timer
>
> [Service]
> EnvironmentFile=-/etc/sysconfig/tsx
> Environment="TMPDIR=/tmp"
> PermissionsStartOnly=true
> ExecStartPre=/usr/bin/chown -R sa-cleanup:root /var/lib/spamassassin/
> ExecStartPre=/usr/bin/find /var/lib/spamassassin/ -type d -exec
> /bin/chmod 0755 "{}" \;
> ExecStartPre=/usr/bin/find /var/lib/spamassassin/ -type f -exec
> /bin/chmod 0644 "{}" \;
> ExecStart=/usr/bin/spamd --max-children=5 --round-robin
> --max-conn-per-child=25 --socketpath=/run/spamassassin/spamassassin.sock
> --socketmode=0666
> ExecReload=/usr/bin/kill -HUP $MAINPID
> Environment="LANG=C.UTF-8"
> *User=sa-milt*
> *Group=sa-milt*
> RuntimeDirectory=spamassassin
> RuntimeDirectoryMode=0775
> StandardOutput=null
> StandardError=null
> SyslogFacility=mail
> Restart=always
> RestartSec=1
> Nice=4
>
> CapabilityBoundingSet=CAP_KILL
> MemoryDenyWriteExecute=yes
> NoNewPrivileges=yes
> PrivateDevices=yes
> PrivateTmp=yes
> ProtectControlGroups=yes
> ProtectKernelModules=yes
> ProtectKernelTunables=yes
> RestrictRealtime=yes
>
>> What part of "OUT OF THE BOX UNMODIFIED are you having trouble with????
>> I guess I'm just a stupid idiot for thinking anything you'd write would
>> work out of the box.
>>
>> On 11/22/2019 5:56 PM, Reindl Harald wrote:
>>> Am 23.11.19 um 00:54 schrieb Jerry Malcolm:
>>>> I don't appreciate you implying I'm a stupid idiot.  That and every bit
>>>> of your language has NO place on this forum, especially your reference
>>>> to my Lord and Savior!!!!
>>>>
>>>> I had NOTHING to do with setting that folder, no matter how STUPID you
>>>> think I am.  That's the folder that appeared in the log file when I ran
>>>> it out of the box.  Why don't you read the full thread before INSULTING
>>>> people.
>>> /root/ does not appear out of the blue
>>>
>>>>>> When running the same SA as a service,
>>>>>> it's NOT looking for bayes in
>>>>>> /root/.spamassassin
>>> you *are* an idiot when you expect to run a service as *root* looking in
>>> /root/ - common sense
>>>
>>>> On 11/22/2019 5:17 PM, Reindl Harald wrote:
>>>>> Am 22.11.19 um 23:06 schrieb Jerry Malcolm:
>>>>>> Well,  I thought I finally had everything resolved.  When I run
>>>>>> spamassassin -D --lint I get the lines:
>>>>>>
>>>>>> Nov 22 21:57:57.954 [13813] dbg: bayes: tie-ing to DB file R/O
>>>>>> /root/.spamassassin/bayes_toks
>>>>>> Nov 22 21:57:57.954 [13813] dbg: bayes: tie-ing to DB file R/O
>>>>>> /root/.spamassassin/bayes_seen
>>>>>> Nov 22 21:57:57.955 [13813] dbg: bayes: found bayes db version 3
>>>>>>
>>>>>> So, I'm ready to start it up as a daemon and start using it... I
>>>>>> checked
>>>>>> /var/log/maillog and see this instead:
>>>>>>
>>>>>> Nov 22 21:58:21 ip-172-31-47-84 spamd[13780]: bayes: no dbs present,
>>>>>> cannot tie DB R/O: /tmp/spamd-13780-init/.spamassassin/bayes_toks
>>>>>>
>>>>>> When running the same SA as a service, it's NOT looking for bayes in
>>>>>> /root/.spamassassin
>>>>> jesus christ why should a service typically not running as root look in
>>>>> roots home directory? why should it even can access it and if it can
>>>>> which idiot ruined your permissions?
>>>>>
>>>>> why the hell are you doing *anything* as root at all?
>>>>>
>>>>> * train bays as the user spamd is running
>>>>> * locate bayes in the homedirectory of that user
>>>>> * done

Re: Where is SA getting config info?

Posted by Jerry Malcolm <te...@malcolms.com>.
What a wonderful way to be treated by a know-it-all arrogant asshole to 
someone who has a problem with your stupid program and simply wants answers.

I DIDN'T DO A THING TO SPECIFY ANYTHING ABOUT ROOT.  THAT IS WHAT 
APPEARS IN THE LOGS RIGHT OUT OF THE BOX.

What part of "OUT OF THE BOX UNMODIFIED are you having trouble with???? 
I guess I'm just a stupid idiot for thinking anything you'd write would 
work out of the box.

On 11/22/2019 5:56 PM, Reindl Harald wrote:
>
> Am 23.11.19 um 00:54 schrieb Jerry Malcolm:
>> I don't appreciate you implying I'm a stupid idiot.  That and every bit
>> of your language has NO place on this forum, especially your reference
>> to my Lord and Savior!!!!
>>
>> I had NOTHING to do with setting that folder, no matter how STUPID you
>> think I am.  That's the folder that appeared in the log file when I ran
>> it out of the box.  Why don't you read the full thread before INSULTING
>> people.
> /root/ does not appear out of the blue
>
>>>> When running the same SA as a service,
>>>> it's NOT looking for bayes in
>>>> /root/.spamassassin
> you *are* an idiot when you expect to run a service as *root* looking in
> /root/ - common sense
>
>> On 11/22/2019 5:17 PM, Reindl Harald wrote:
>>> Am 22.11.19 um 23:06 schrieb Jerry Malcolm:
>>>> Well,  I thought I finally had everything resolved.  When I run
>>>> spamassassin -D --lint I get the lines:
>>>>
>>>> Nov 22 21:57:57.954 [13813] dbg: bayes: tie-ing to DB file R/O
>>>> /root/.spamassassin/bayes_toks
>>>> Nov 22 21:57:57.954 [13813] dbg: bayes: tie-ing to DB file R/O
>>>> /root/.spamassassin/bayes_seen
>>>> Nov 22 21:57:57.955 [13813] dbg: bayes: found bayes db version 3
>>>>
>>>> So, I'm ready to start it up as a daemon and start using it... I checked
>>>> /var/log/maillog and see this instead:
>>>>
>>>> Nov 22 21:58:21 ip-172-31-47-84 spamd[13780]: bayes: no dbs present,
>>>> cannot tie DB R/O: /tmp/spamd-13780-init/.spamassassin/bayes_toks
>>>>
>>>> When running the same SA as a service, it's NOT looking for bayes in
>>>> /root/.spamassassin
>>> jesus christ why should a service typically not running as root look in
>>> roots home directory? why should it even can access it and if it can
>>> which idiot ruined your permissions?
>>>
>>> why the hell are you doing *anything* as root at all?
>>>
>>> * train bays as the user spamd is running
>>> * locate bayes in the homedirectory of that user
>>> * done

Re: Where is SA getting config info?

Posted by Jerry Malcolm <te...@malcolms.com>.
I don't appreciate you implying I'm a stupid idiot.  That and every bit 
of your language has NO place on this forum, especially your reference 
to my Lord and Savior!!!!

I had NOTHING to do with setting that folder, no matter how STUPID you 
think I am.  That's the folder that appeared in the log file when I ran 
it out of the box.  Why don't you read the full thread before INSULTING 
people.


On 11/22/2019 5:17 PM, Reindl Harald wrote:
>
> Am 22.11.19 um 23:06 schrieb Jerry Malcolm:
>> Well,  I thought I finally had everything resolved.  When I run
>> spamassassin -D --lint I get the lines:
>>
>> Nov 22 21:57:57.954 [13813] dbg: bayes: tie-ing to DB file R/O
>> /root/.spamassassin/bayes_toks
>> Nov 22 21:57:57.954 [13813] dbg: bayes: tie-ing to DB file R/O
>> /root/.spamassassin/bayes_seen
>> Nov 22 21:57:57.955 [13813] dbg: bayes: found bayes db version 3
>>
>> So, I'm ready to start it up as a daemon and start using it... I checked
>> /var/log/maillog and see this instead:
>>
>> Nov 22 21:58:21 ip-172-31-47-84 spamd[13780]: bayes: no dbs present,
>> cannot tie DB R/O: /tmp/spamd-13780-init/.spamassassin/bayes_toks
>>
>> When running the same SA as a service, it's NOT looking for bayes in
>> /root/.spamassassin
> jesus christ why should a service typically not running as root look in
> roots home directory? why should it even can access it and if it can
> which idiot ruined your permissions?
>
> why the hell are you doing *anything* as root at all?
>
> * train bays as the user spamd is running
> * locate bayes in the homedirectory of that user
> * done
>
>
>

Re: Where is SA getting config info?

Posted by Jerry Malcolm <te...@malcolms.com>.
Well,  I thought I finally had everything resolved.  When I run 
spamassassin -D --lint I get the lines:

Nov 22 21:57:57.954 [13813] dbg: bayes: tie-ing to DB file R/O 
/root/.spamassassin/bayes_toks
Nov 22 21:57:57.954 [13813] dbg: bayes: tie-ing to DB file R/O 
/root/.spamassassin/bayes_seen
Nov 22 21:57:57.955 [13813] dbg: bayes: found bayes db version 3

So, I'm ready to start it up as a daemon and start using it... I checked 
/var/log/maillog and see this instead:

Nov 22 21:58:21 ip-172-31-47-84 spamd[13780]: bayes: no dbs present, 
cannot tie DB R/O: /tmp/spamd-13780-init/.spamassassin/bayes_toks

When running the same SA as a service, it's NOT looking for bayes in 
/root/.spamassassin.  Rather it's trying to find it in some random name 
temp folder.

What am I doing wrong this time?

Thx


On 11/22/2019 1:38 PM, Jerry Malcolm wrote:
> Kris,
>
> This was exactly the info I was looking for.  Thank you so much. I'm 
> down to one issue with the bayes_path parm.  From what you have 
> described, I assume what I put in local.cf is being overridden by some 
> other cf file.  I really don't care at this point what folder to use.  
> I just moved my bayes_toks file to the folder SA is saying it wants to 
> use.
>
> My last problem (for today) is figuring out how to get my old 
> bayes_toks into a format that the current SA likes.  I posted that in 
> a separate thread.  Thank you again.
>
> Jerry
>
> On 11/22/2019 1:17 PM, Kris Deugau wrote:
>> Jerry Malcolm wrote:
>>> I am trying to add bayes to SA.  I see in the docs that there is a 
>>> use_bayes parm and the path parm. I made the changes to 
>>> /usr/share/spamassassin/local.cf.  But I see no change.  I am not 
>>> sure it's even loading that config file. I've got debug on, and the 
>>> log doesn't tell me that it's reading the local.cf file I'm changing.
>>
>> SA's core rules used to be loaded from /usr/share/spamassassin, but 
>> it's mostly just a last-resort fallback at this point. Active core 
>> rules are loaded from /var/lib/spamassassin, and updated 
>> automatically with sa-update.  You're making changes to a file that 
>> may not even be looked at, and if it is it's overridden by files 
>> loaded later.
>>
>> You shouldn't change files in either location, because they'll be 
>> overwritten without notice (on package upgrades, for the files in 
>> /usr/share/spamassassin;  on the next ruleset update by sa-update for 
>> /var/lib/spamassassin).
>>
>>> I think I need to go back to the basics. I simply want a 100% 
>>> site-wide SA (no per-user anything). I've read of the config docs. 
>>> It describes every parameter. But it doesn't really put the big 
>>> picture together. Is there a "SpamAssassin for Dummies" doc that 
>>> describes the command line args for 'site-wide-only' and also which 
>>> config file (local.cf?) in which folder I should be changing?
>>
>> Your own local configuration for SA should be almost entirely in 
>> /etc/spamassassin or /etc/mail/spamassassin depending on how SA was 
>> packaged.  SA will load any file ending with .cf from this directory.
>>
>> The first few lines of the debug output should show something like:
>>
>> Nov 22 13:46:46.298 [26759] dbg: generic: Perl 5.020002, PREFIX=/usr, 
>> DEF_RULES_DIR=/usr/share/spamassassin, 
>> LOCAL_RULES_DIR=/etc/spamassassin, LOCAL_STATE_DIR=/var/lib/spamassassin
>>
>> SA will look for rules in DEF_RULES_DIR, LOCAL_STATE_DIR, then 
>> LOCAL_RULES_DIR, whatever they're set to.  Each later directory tree 
>> overrides anything set in an earlier one.
>>
>>> The initial install of SA on AWS Linux EC2 has a SPAMDOPTIONS="-d -c 
>>> -m5 -H".  I was told a few months back in this forum that -H without 
>>> a parameter following is not even valid and it applies to per-user 
>>> stuff. So I removed the -H.  I read that -c creates a user pref file 
>>> which sounds like per-user.  So I removed that. But the log is 
>>> telling me it's loading files from /etc/mail which I thought the 
>>> docs said was per-user stuff.  Basically, I can't figure out how to 
>>> make any config changes that are actually seen by SA.
>>
>> A few fragments for the spamd daemon arguments should be in 
>> /etc/sysconfig/spamassassin on Red Hat and derivatives like AW Linux. 
>> (The actual file might be spamd;  it's been a while since I used RH 
>> systems for SA.)
>>
>> Make your local changes in this file;  like the SA rules, the init 
>> script in /etc/init.d will also be overwritten without notice on a 
>> package upgrade.
>>
>>> So... questions:
>>>
>>>      -- first just to make SA run as 'site-wide-only', should the 
>>> command line args be "-d -m5"? (or do I really need to go back to 
>>> "-d -c -m5 -H"?
>>
>> No, removing those options is OK for your use.  You will probably 
>> want to add -x to skip loading per-user configuration.
>>
>> You may want to add "-u spamd" to make sure spamd is running as its 
>> own unprivileged user.  The specific user might be something else - 
>> for instance the Debian packages provide a "debian-spamd" user 
>> instead. You'll have to check /etc/passwd to see if one was created, 
>> and what it is.
>>
>> Check the spamd man page for any other options you might want set.
>>
>>>      -- What file should I be changing to adjust config?  If it's 
>>> indeed /usr/share/spamassassin/local.cf, is there something I can 
>>> change in there that I can force something in the log file to assure 
>>> me that config parms are really being pulled from here?
>>
>> Your configuration can go in any .cf file in /etc/mail/spamassassin.  
>> By convention, local.cf should have your major options (sitewide 
>> Bayes, message tagging method, default "this is spam" threshold, 
>> etc), but there's nothing in the SA code that makes it special IIRC.
>>
>> If you just have a few extra things to add, it's probably easiest to 
>> add them to this file.  If you have a long list of things (eg a long 
>> local blacklist and/or whitelist) you may want to put them in 
>> different .cf files for convenient management.
>>
>>>      -- Shouldn't "use_bayes 1" cause something to appear in the 
>>> debug log saying something about bayes now in use (and something 
>>> about the bayes_toks file)?
>>
>> Only if not overridden by a "later" file.  Initially most of the 
>> messages you'll see should indicate that Bayes has not been trained 
>> with enough messages.  For sitewide operation you'll need to set 
>> bayes_path or the related database-related options to force SA to use 
>> your sitewide Bayes database instead of a per-user one.
>>
>>>      -- Finally, where should I put custom rule files such as KAM.cf 
>>> so they are used, but not erased with sa_update?
>>
>> /etc/mail/spamassassin, alongside local.cf.
>>
>>> If all of this is explained in some user scenario docs, please point 
>>> me to them.  It's just really tough getting the big picture here 
>>> especially when I can't get ANY config changes to make any difference.
>>
>> Spend a while reading the Mail::SpamAssassin::Conf manpage. Most of 
>> the SA configuration is documented here.
>>
>> -kgd

Re: Where is SA getting config info?

Posted by Jerry Malcolm <te...@malcolms.com>.
Kris,

This was exactly the info I was looking for.  Thank you so much. I'm 
down to one issue with the bayes_path parm.  From what you have 
described, I assume what I put in local.cf is being overridden by some 
other cf file.  I really don't care at this point what folder to use.  I 
just moved my bayes_toks file to the folder SA is saying it wants to use.

My last problem (for today) is figuring out how to get my old bayes_toks 
into a format that the current SA likes.  I posted that in a separate 
thread.  Thank you again.

Jerry

On 11/22/2019 1:17 PM, Kris Deugau wrote:
> Jerry Malcolm wrote:
>> I am trying to add bayes to SA.  I see in the docs that there is a 
>> use_bayes parm and the path parm.  I made the changes to 
>> /usr/share/spamassassin/local.cf.  But I see no change.  I am not 
>> sure it's even loading that config file. I've got debug on, and the 
>> log doesn't tell me that it's reading the local.cf file I'm changing.
>
> SA's core rules used to be loaded from /usr/share/spamassassin, but 
> it's mostly just a last-resort fallback at this point.  Active core 
> rules are loaded from /var/lib/spamassassin, and updated automatically 
> with sa-update.  You're making changes to a file that may not even be 
> looked at, and if it is it's overridden by files loaded later.
>
> You shouldn't change files in either location, because they'll be 
> overwritten without notice (on package upgrades, for the files in 
> /usr/share/spamassassin;  on the next ruleset update by sa-update for 
> /var/lib/spamassassin).
>
>> I think I need to go back to the basics. I simply want a 100% 
>> site-wide SA (no per-user anything).  I've read of the config docs. 
>> It describes every parameter.  But it doesn't really put the big 
>> picture together. Is there a "SpamAssassin for Dummies" doc that 
>> describes the command line args for 'site-wide-only' and also which 
>> config file (local.cf?) in which folder I should be changing?
>
> Your own local configuration for SA should be almost entirely in 
> /etc/spamassassin or /etc/mail/spamassassin depending on how SA was 
> packaged.  SA will load any file ending with .cf from this directory.
>
> The first few lines of the debug output should show something like:
>
> Nov 22 13:46:46.298 [26759] dbg: generic: Perl 5.020002, PREFIX=/usr, 
> DEF_RULES_DIR=/usr/share/spamassassin, 
> LOCAL_RULES_DIR=/etc/spamassassin, LOCAL_STATE_DIR=/var/lib/spamassassin
>
> SA will look for rules in DEF_RULES_DIR, LOCAL_STATE_DIR, then 
> LOCAL_RULES_DIR, whatever they're set to.  Each later directory tree 
> overrides anything set in an earlier one.
>
>> The initial install of SA on AWS Linux EC2 has a SPAMDOPTIONS="-d -c 
>> -m5 -H".  I was told a few months back in this forum that -H without 
>> a parameter following is not even valid and it applies to per-user 
>> stuff. So I removed the -H.  I read that -c creates a user pref file 
>> which sounds like per-user.  So I removed that. But the log is 
>> telling me it's loading files from /etc/mail which I thought the docs 
>> said was per-user stuff.  Basically, I can't figure out how to make 
>> any config changes that are actually seen by SA.
>
> A few fragments for the spamd daemon arguments should be in 
> /etc/sysconfig/spamassassin on Red Hat and derivatives like AW Linux. 
> (The actual file might be spamd;  it's been a while since I used RH 
> systems for SA.)
>
> Make your local changes in this file;  like the SA rules, the init 
> script in /etc/init.d will also be overwritten without notice on a 
> package upgrade.
>
>> So... questions:
>>
>>      -- first just to make SA run as 'site-wide-only', should the 
>> command line args be "-d -m5"? (or do I really need to go back to "-d 
>> -c -m5 -H"?
>
> No, removing those options is OK for your use.  You will probably want 
> to add -x to skip loading per-user configuration.
>
> You may want to add "-u spamd" to make sure spamd is running as its 
> own unprivileged user.  The specific user might be something else - 
> for instance the Debian packages provide a "debian-spamd" user 
> instead. You'll have to check /etc/passwd to see if one was created, 
> and what it is.
>
> Check the spamd man page for any other options you might want set.
>
>>      -- What file should I be changing to adjust config?  If it's 
>> indeed /usr/share/spamassassin/local.cf, is there something I can 
>> change in there that I can force something in the log file to assure 
>> me that config parms are really being pulled from here?
>
> Your configuration can go in any .cf file in /etc/mail/spamassassin.  
> By convention, local.cf should have your major options (sitewide 
> Bayes, message tagging method, default "this is spam" threshold, etc), 
> but there's nothing in the SA code that makes it special IIRC.
>
> If you just have a few extra things to add, it's probably easiest to 
> add them to this file.  If you have a long list of things (eg a long 
> local blacklist and/or whitelist) you may want to put them in 
> different .cf files for convenient management.
>
>>      -- Shouldn't "use_bayes 1" cause something to appear in the 
>> debug log saying something about bayes now in use (and something 
>> about the bayes_toks file)?
>
> Only if not overridden by a "later" file.  Initially most of the 
> messages you'll see should indicate that Bayes has not been trained 
> with enough messages.  For sitewide operation you'll need to set 
> bayes_path or the related database-related options to force SA to use 
> your sitewide Bayes database instead of a per-user one.
>
>>      -- Finally, where should I put custom rule files such as KAM.cf 
>> so they are used, but not erased with sa_update?
>
> /etc/mail/spamassassin, alongside local.cf.
>
>> If all of this is explained in some user scenario docs, please point 
>> me to them.  It's just really tough getting the big picture here 
>> especially when I can't get ANY config changes to make any difference.
>
> Spend a while reading the Mail::SpamAssassin::Conf manpage.  Most of 
> the SA configuration is documented here.
>
> -kgd

Re: Where is SA getting config info?

Posted by Kris Deugau <kd...@vianet.ca>.
Jerry Malcolm wrote:
> I am trying to add bayes to SA.  I see in the docs that there is a 
> use_bayes parm and the path parm.  I made the changes to 
> /usr/share/spamassassin/local.cf.  But I see no change.  I am not sure 
> it's even loading that config file. I've got debug on, and the log 
> doesn't tell me that it's reading the local.cf file I'm changing.

SA's core rules used to be loaded from /usr/share/spamassassin, but it's 
mostly just a last-resort fallback at this point.  Active core rules are 
loaded from /var/lib/spamassassin, and updated automatically with 
sa-update.  You're making changes to a file that may not even be looked 
at, and if it is it's overridden by files loaded later.

You shouldn't change files in either location, because they'll be 
overwritten without notice (on package upgrades, for the files in 
/usr/share/spamassassin;  on the next ruleset update by sa-update for 
/var/lib/spamassassin).

> I think I need to go back to the basics.  I simply want a 100% site-wide 
> SA (no per-user anything).  I've read of the config docs. It describes 
> every parameter.  But it doesn't really put the big picture together. Is 
> there a "SpamAssassin for Dummies" doc that describes the command line 
> args for 'site-wide-only' and also which config file (local.cf?) in 
> which folder I should be changing?

Your own local configuration for SA should be almost entirely in 
/etc/spamassassin or /etc/mail/spamassassin depending on how SA was 
packaged.  SA will load any file ending with .cf from this directory.

The first few lines of the debug output should show something like:

Nov 22 13:46:46.298 [26759] dbg: generic: Perl 5.020002, PREFIX=/usr, 
DEF_RULES_DIR=/usr/share/spamassassin, 
LOCAL_RULES_DIR=/etc/spamassassin, LOCAL_STATE_DIR=/var/lib/spamassassin

SA will look for rules in DEF_RULES_DIR, LOCAL_STATE_DIR, then 
LOCAL_RULES_DIR, whatever they're set to.  Each later directory tree 
overrides anything set in an earlier one.

> The initial install of SA on AWS Linux EC2 has a SPAMDOPTIONS="-d -c -m5 
> -H".  I was told a few months back in this forum that -H without a 
> parameter following is not even valid and it applies to per-user stuff. 
> So I removed the -H.  I read that -c creates a user pref file which 
> sounds like per-user.  So I removed that. But the log is telling me it's 
> loading files from /etc/mail which I thought the docs said was per-user 
> stuff.  Basically, I can't figure out how to make any config changes 
> that are actually seen by SA.

A few fragments for the spamd daemon arguments should be in 
/etc/sysconfig/spamassassin on Red Hat and derivatives like AW Linux. 
(The actual file might be spamd;  it's been a while since I used RH 
systems for SA.)

Make your local changes in this file;  like the SA rules, the init 
script in /etc/init.d will also be overwritten without notice on a 
package upgrade.

> So... questions:
> 
>      -- first just to make SA run as 'site-wide-only', should the 
> command line args be "-d -m5"? (or do I really need to go back to "-d -c 
> -m5 -H"?

No, removing those options is OK for your use.  You will probably want 
to add -x to skip loading per-user configuration.

You may want to add "-u spamd" to make sure spamd is running as its own 
unprivileged user.  The specific user might be something else - for 
instance the Debian packages provide a "debian-spamd" user instead. 
You'll have to check /etc/passwd to see if one was created, and what it is.

Check the spamd man page for any other options you might want set.

>      -- What file should I be changing to adjust config?  If it's indeed 
> /usr/share/spamassassin/local.cf, is there something I can change in 
> there that I can force something in the log file to assure me that 
> config parms are really being pulled from here?

Your configuration can go in any .cf file in /etc/mail/spamassassin.  By 
convention, local.cf should have your major options (sitewide Bayes, 
message tagging method, default "this is spam" threshold, etc), but 
there's nothing in the SA code that makes it special IIRC.

If you just have a few extra things to add, it's probably easiest to add 
them to this file.  If you have a long list of things (eg a long local 
blacklist and/or whitelist) you may want to put them in different .cf 
files for convenient management.

>      -- Shouldn't "use_bayes 1" cause something to appear in the debug 
> log saying something about bayes now in use (and something about the 
> bayes_toks file)?

Only if not overridden by a "later" file.  Initially most of the 
messages you'll see should indicate that Bayes has not been trained with 
enough messages.  For sitewide operation you'll need to set bayes_path 
or the related database-related options to force SA to use your sitewide 
Bayes database instead of a per-user one.

>      -- Finally, where should I put custom rule files such as KAM.cf so 
> they are used, but not erased with sa_update?

/etc/mail/spamassassin, alongside local.cf.

> If all of this is explained in some user scenario docs, please point me 
> to them.  It's just really tough getting the big picture here especially 
> when I can't get ANY config changes to make any difference.

Spend a while reading the Mail::SpamAssassin::Conf manpage.  Most of the 
SA configuration is documented here.

-kgd