--- rpms/smeserver-learn/contribs10/smeserver-learn-1.0-bz11281-bz10732-bz9524.patch 2021/02/23 19:41:54 1.2 +++ rpms/smeserver-learn/contribs10/smeserver-learn-1.0-bz11281-bz10732-bz9524.patch 2021/02/23 21:05:48 1.3 @@ -55,8 +55,8 @@ diff -Nur smeserver-learn-1.0.old/root/e +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 +--- smeserver-learn-1.0.old/root/usr/bin/Learn.pl 2021-02-23 14:47:51.066000000 -0500 ++++ smeserver-learn-1.0/root/usr/bin/Learn.pl 2021-02-23 16:04:45.733000000 -0500 @@ -20,6 +20,7 @@ use Digest::MD5 qw(md5 md5_hex md5_base64); use File::Find; @@ -65,18 +65,63 @@ diff -Nur smeserver-learn-1.0.old/root/u use File::Basename; use File::Path; use Encode qw/encode decode/; -@@ -121,6 +122,10 @@ +@@ -42,7 +43,7 @@ + my $agesecs=60*60*24*$DelayToMove; #converts $agedays to seconds + my $daysago=time-$agesecs; #the time stamp of $agedays ago in seconds + my $daysago2=localtime($daysago); #the time stamp of $agedays ago in words - mainly for printing +-my $SpamLinks = $sadb->get_prop("LearnAsSpam", "SpamLinks") or ""; ++my $SpamLinks = $sadb->get_prop("LearnAsSpam", "SpamLinks") || ""; + my @files; + + #getting user list +@@ -103,10 +104,9 @@ + my @logdirs = ($sadb->get_prop($mode, "Uniq") eq "enabled")? sort grep { /^$dirname$/ } readdir(LOGDIR) :sort grep { /$dirname/ } readdir(LOGDIR); + closedir(LOGDIR); + ++ ($login,$pass,$uid,$gid) = getpwnam($key) or die "$key not in passwd file"; + # mk dir if not exist + if (! @logdirs and ($sadb->get_prop($mode, "Uniq") eq "enabled")) { +- ($login,$pass,$uid,$gid) = getpwnam($key) +- or die "$key not in passwd file"; + Vact();print "+->mkdir :". $MailDir . "/" . $dirname . "\n"; + foreach $a ('','/cur','/tmp','/new'){ + mkdir $MailDir . "/" . $dirname . "$a"; +@@ -115,12 +115,32 @@ + }; + + my $junkdir = $MailDir . "/.junkmail"; ++ unless ( -d $junkdir ) { ++ Vact();print "+->mkdir :". $junkdir . "\n"; ++ foreach $a ('','/cur','/tmp','/new'){ ++ mkdir $junkdir . "/" . "$a"; ++ chown $uid,$gid,$junkdir . "/" . "$a"; ++ } ++ ++ } ++ + # create junkmail links if necessary +- if ($mode eq "LearnAsSpam" and ($SpamLinks or $user->prop('SpamLinks') ) ) { +- $Spamlinks= $Spamlinks ? $Spamlinks .",".$user->prop('SpamLinks'): $user->prop('SpamLinks') if ($user->prop('SpamLinks')); ++ my $Spamlinks = $user->prop('SpamLinks') || ""; ++ if ($mode eq "LearnAsSpam" and ($SpamLinks or $Spamlinks ) ) { ++ $Spamlinks= $SpamLinks ? $SpamLinks .",". $Spamlinks : $Spamlinks; ++ $Spamlinks =~ s/,$//; foreach $a (split(",",$Spamlinks)){ $a=(substr($a, 0, 1) eq '.')? $a: ".$a"; my $Link= $MailDir . "/" . $a; -+ continue if ( -l $Link); ++ next if ( $Link eq ".." || $Link eq "." || $Link eq "" ); ++ next 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: $!"; ++ Vact(); print "+->move previous dir $Link content to $junkdir\n"; ++ File::Copy::Recursive::dirmove($Link, $junkdir) or die "Can't move folder in place of our wanted link from %Link to $junkdir: $!"; ++ #side effect : ownership is lost ++ @files = ( glob( $junkdir . '/cur/*' ),glob( $junkdir . '/new/*' ), glob( $junkdir . '/tmp/*' ) ); ++ chown $uid, $gid, @files; + }; 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 @@ +@@ -209,6 +229,10 @@ for my $test ( quotemeta $subjectTAG , quotemeta $tag) { ($Subject= $Subject) =~ s/$test//; } @@ -87,12 +132,12 @@ diff -Nur smeserver-learn-1.0.old/root/u } # encoding as MIME Q (not B) with UTF8 as default. my $cleanTag= encode("MIME-Q",$sadb->get_prop($mode, "tag")); -@@ -243,7 +252,7 @@ +@@ -243,7 +267,7 @@ if ($newmd5 ne $md5) { `expand-template /etc/mail/spamassassin/local.cf`; -+ `/usr/bin/systemctl restart spamassassin.service`; - `/etc/init.d/spamd restart`; ++ `/usr/bin/systemctl restart spamassassin.service`; print "\n"; }