diff -Nur smeserver-learn-1.0.old/createlinks smeserver-learn-1.0/createlinks --- smeserver-learn-1.0.old/createlinks 2021-02-23 13:32:11.805000000 -0500 +++ smeserver-learn-1.0/createlinks 2021-02-23 14:23:16.390000000 -0500 @@ -7,3 +7,8 @@ safe_touch('root/etc/e-smith/db/configuration/defaults/Learn/Exclude'); safe_touch('root/etc/e-smith/db/configuration/defaults/Learn/Include'); +my $event="smeserver-learn-update"; +templates2events("/etc/cron.d/Learn",$event); +templates2events("/etc/mail/spamassassin/local.cf",$event); +event_link("LearnSpam-init", $event, "04"); +event_link("LearnSpam-run", $event, "30"); diff -Nur smeserver-learn-1.0.old/root/etc/e-smith/db/configuration/force/spamassassin/status smeserver-learn-1.0/root/etc/e-smith/db/configuration/force/spamassassin/status --- smeserver-learn-1.0.old/root/etc/e-smith/db/configuration/force/spamassassin/status 1969-12-31 19:00:00.000000000 -0500 +++ smeserver-learn-1.0/root/etc/e-smith/db/configuration/force/spamassassin/status 2021-02-23 14:19:59.599000000 -0500 @@ -0,0 +1 @@ +enabled diff -Nur smeserver-learn-1.0.old/root/etc/e-smith/db/configuration/force/spamassassin/UseBayes smeserver-learn-1.0/root/etc/e-smith/db/configuration/force/spamassassin/UseBayes --- smeserver-learn-1.0.old/root/etc/e-smith/db/configuration/force/spamassassin/UseBayes 1969-12-31 19:00:00.000000000 -0500 +++ smeserver-learn-1.0/root/etc/e-smith/db/configuration/force/spamassassin/UseBayes 2021-02-23 14:20:19.445000000 -0500 @@ -0,0 +1 @@ +1 diff -Nur smeserver-learn-1.0.old/root/etc/e-smith/events/actions/LearnSpam-init smeserver-learn-1.0/root/etc/e-smith/events/actions/LearnSpam-init --- smeserver-learn-1.0.old/root/etc/e-smith/events/actions/LearnSpam-init 1969-12-31 19:00:00.000000000 -0500 +++ smeserver-learn-1.0/root/etc/e-smith/events/actions/LearnSpam-init 2021-02-23 14:32:38.915000000 -0500 @@ -0,0 +1,20 @@ +#!/bin/bash + +# default is 0, if kept to 0 we can not play there +/sbin/e-smith/db configuration setprop spamassassin UseBayes 1 + +# default is empty, we shall set it if we want to have a run +/sbin/e-smith/config getprop spamassassin BayesAutoLearnThresholdSpam >/dev/null|| /sbin/e-smith/config setprop spamassassin BayesAutoLearnThresholdSpam 6.00 +/sbin/e-smith/config getprop spamassassin BayesAutoLearnThresholdNonspam >/dev/null|| /sbin/e-smith/config setprop spamassassin BayesAutoLearnThresholdNonspam 0.10 + +# we really need spamassassin running +/sbin/e-smith/config setprop spamassassin status enabled + +# default is 0 for no reject +#/sbin/e-smith/config setprop spamassassin RejectLevel 12 + +# default is 5 +#/sbin/e-smith/config setprop spamassassin TagLevel 4 + +# default is medium +#/sbin/e-smith/config setprop spamassassin Sensitivity custom diff -Nur smeserver-learn-1.0.old/root/etc/e-smith/events/actions/LearnSpam-run smeserver-learn-1.0/root/etc/e-smith/events/actions/LearnSpam-run --- smeserver-learn-1.0.old/root/etc/e-smith/events/actions/LearnSpam-run 1969-12-31 19:00:00.000000000 -0500 +++ smeserver-learn-1.0/root/etc/e-smith/events/actions/LearnSpam-run 2021-02-23 14:21:17.357000000 -0500 @@ -0,0 +1,6 @@ +#!/bin/bash + +sa-learn --sync --dbpath /var/spool/spamd/.spamassassin -u spamd +chown spamd.spamd /var/spool/spamd/.spamassassin/bayes_* +chown spamd.spamd /var/spool/spamd/.spamassassin/bayes.mutex +chmod 640 /var/spool/spamd/.spamassassin/bayes_* diff -Nur smeserver-learn-1.0.old/root/usr/bin/Learn.pl smeserver-learn-1.0/root/usr/bin/Learn.pl --- smeserver-learn-1.0.old/root/usr/bin/Learn.pl 2021-02-23 14:26:06.472000000 -0500 +++ smeserver-learn-1.0/root/usr/bin/Learn.pl 2021-02-23 14:01:57.297000000 -0500 @@ -20,6 +20,7 @@ use Digest::MD5 qw(md5 md5_hex md5_base64); use File::Find; use File::Copy; +use File::Copy::Recursive; use File::Basename; use File::Path; use Encode qw/encode decode/; @@ -121,6 +122,10 @@ foreach $a (split(",",$Spamlinks)){ $a=(substr($a, 0, 1) eq '.')? $a: ".$a"; my $Link= $MailDir . "/" . $a; + continue if ( -l $Link); + if (-d $Link) { + dirmove($Link, $junkdir) or die "Can't move folder in place of our wanted link from %Link to $junkdir: $!"; + }; if (! -e $Link) { Vact(); print "+->create link $Link on $junkdir\n"; symlink($junkdir, $Link) or die "Can't create symlink from $Link to $junkdir: $!"; @@ -209,6 +214,10 @@ for my $test ( quotemeta $subjectTAG , quotemeta $tag) { ($Subject= $Subject) =~ s/$test//; } + # we also remove Spam tag or client will move the mail again in spam dir + $email->header_set("X-Spam-Flag",'NO'); + $email->header_set("X-Spam-Level",'*'); + $email->header_set("X-Spam-Status",'No, score=0.0 required=4.0 autolearn=disabled'); } # encoding as MIME Q (not B) with UTF8 as default. my $cleanTag= encode("MIME-Q",$sadb->get_prop($mode, "tag")); @@ -243,7 +252,7 @@ if ($newmd5 ne $md5) { `expand-template /etc/mail/spamassassin/local.cf`; - `/usr/bin/systemctl restart spamassassin.service`; + `/etc/init.d/spamd restart`; print "\n"; }