55 |
+chown spamd.spamd /var/spool/spamd/.spamassassin/bayes.mutex |
+chown spamd.spamd /var/spool/spamd/.spamassassin/bayes.mutex |
56 |
+chmod 640 /var/spool/spamd/.spamassassin/bayes_* |
+chmod 640 /var/spool/spamd/.spamassassin/bayes_* |
57 |
diff -Nur smeserver-learn-1.0.old/root/usr/bin/Learn.pl smeserver-learn-1.0/root/usr/bin/Learn.pl |
diff -Nur smeserver-learn-1.0.old/root/usr/bin/Learn.pl smeserver-learn-1.0/root/usr/bin/Learn.pl |
58 |
--- smeserver-learn-1.0.old/root/usr/bin/Learn.pl 2021-02-23 14:26:06.472000000 -0500 |
--- smeserver-learn-1.0.old/root/usr/bin/Learn.pl 2021-02-23 14:47:51.066000000 -0500 |
59 |
+++ smeserver-learn-1.0/root/usr/bin/Learn.pl 2021-02-23 14:01:57.297000000 -0500 |
+++ smeserver-learn-1.0/root/usr/bin/Learn.pl 2021-02-23 16:04:45.733000000 -0500 |
60 |
@@ -20,6 +20,7 @@ |
@@ -20,6 +20,7 @@ |
61 |
use Digest::MD5 qw(md5 md5_hex md5_base64); |
use Digest::MD5 qw(md5 md5_hex md5_base64); |
62 |
use File::Find; |
use File::Find; |
65 |
use File::Basename; |
use File::Basename; |
66 |
use File::Path; |
use File::Path; |
67 |
use Encode qw/encode decode/; |
use Encode qw/encode decode/; |
68 |
@@ -121,6 +122,10 @@ |
@@ -42,7 +43,7 @@ |
69 |
|
my $agesecs=60*60*24*$DelayToMove; #converts $agedays to seconds |
70 |
|
my $daysago=time-$agesecs; #the time stamp of $agedays ago in seconds |
71 |
|
my $daysago2=localtime($daysago); #the time stamp of $agedays ago in words - mainly for printing |
72 |
|
-my $SpamLinks = $sadb->get_prop("LearnAsSpam", "SpamLinks") or ""; |
73 |
|
+my $SpamLinks = $sadb->get_prop("LearnAsSpam", "SpamLinks") || ""; |
74 |
|
my @files; |
75 |
|
|
76 |
|
#getting user list |
77 |
|
@@ -103,10 +104,9 @@ |
78 |
|
my @logdirs = ($sadb->get_prop($mode, "Uniq") eq "enabled")? sort grep { /^$dirname$/ } readdir(LOGDIR) :sort grep { /$dirname/ } readdir(LOGDIR); |
79 |
|
closedir(LOGDIR); |
80 |
|
|
81 |
|
+ ($login,$pass,$uid,$gid) = getpwnam($key) or die "$key not in passwd file"; |
82 |
|
# mk dir if not exist |
83 |
|
if (! @logdirs and ($sadb->get_prop($mode, "Uniq") eq "enabled")) { |
84 |
|
- ($login,$pass,$uid,$gid) = getpwnam($key) |
85 |
|
- or die "$key not in passwd file"; |
86 |
|
Vact();print "+->mkdir :". $MailDir . "/" . $dirname . "\n"; |
87 |
|
foreach $a ('','/cur','/tmp','/new'){ |
88 |
|
mkdir $MailDir . "/" . $dirname . "$a"; |
89 |
|
@@ -115,12 +115,32 @@ |
90 |
|
}; |
91 |
|
|
92 |
|
my $junkdir = $MailDir . "/.junkmail"; |
93 |
|
+ unless ( -d $junkdir ) { |
94 |
|
+ Vact();print "+->mkdir :". $junkdir . "\n"; |
95 |
|
+ foreach $a ('','/cur','/tmp','/new'){ |
96 |
|
+ mkdir $junkdir . "/" . "$a"; |
97 |
|
+ chown $uid,$gid,$junkdir . "/" . "$a"; |
98 |
|
+ } |
99 |
|
+ |
100 |
|
+ } |
101 |
|
+ |
102 |
|
# create junkmail links if necessary |
103 |
|
- if ($mode eq "LearnAsSpam" and ($SpamLinks or $user->prop('SpamLinks') ) ) { |
104 |
|
- $Spamlinks= $Spamlinks ? $Spamlinks .",".$user->prop('SpamLinks'): $user->prop('SpamLinks') if ($user->prop('SpamLinks')); |
105 |
|
+ my $Spamlinks = $user->prop('SpamLinks') || ""; |
106 |
|
+ if ($mode eq "LearnAsSpam" and ($SpamLinks or $Spamlinks ) ) { |
107 |
|
+ $Spamlinks= $SpamLinks ? $SpamLinks .",". $Spamlinks : $Spamlinks; |
108 |
|
+ $Spamlinks =~ s/,$//; |
109 |
foreach $a (split(",",$Spamlinks)){ |
foreach $a (split(",",$Spamlinks)){ |
110 |
$a=(substr($a, 0, 1) eq '.')? $a: ".$a"; |
$a=(substr($a, 0, 1) eq '.')? $a: ".$a"; |
111 |
my $Link= $MailDir . "/" . $a; |
my $Link= $MailDir . "/" . $a; |
112 |
+ continue if ( -l $Link); |
+ next if ( $Link eq ".." || $Link eq "." || $Link eq "" ); |
113 |
|
+ next if ( -l $Link); |
114 |
+ if (-d $Link) { |
+ if (-d $Link) { |
115 |
+ 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"; |
116 |
|
+ File::Copy::Recursive::dirmove($Link, $junkdir) or die "Can't move folder in place of our wanted link from %Link to $junkdir: $!"; |
117 |
|
+ #side effect : ownership is lost |
118 |
|
+ @files = ( glob( $junkdir . '/cur/*' ),glob( $junkdir . '/new/*' ), glob( $junkdir . '/tmp/*' ) ); |
119 |
|
+ chown $uid, $gid, @files; |
120 |
+ }; |
+ }; |
121 |
if (! -e $Link) { |
if (! -e $Link) { |
122 |
Vact(); print "+->create link $Link on $junkdir\n"; |
Vact(); print "+->create link $Link on $junkdir\n"; |
123 |
symlink($junkdir, $Link) or die "Can't create symlink from $Link to $junkdir: $!"; |
symlink($junkdir, $Link) or die "Can't create symlink from $Link to $junkdir: $!"; |
124 |
@@ -209,6 +214,10 @@ |
@@ -209,6 +229,10 @@ |
125 |
for my $test ( quotemeta $subjectTAG , quotemeta $tag) { |
for my $test ( quotemeta $subjectTAG , quotemeta $tag) { |
126 |
($Subject= $Subject) =~ s/$test//; |
($Subject= $Subject) =~ s/$test//; |
127 |
} |
} |
132 |
} |
} |
133 |
# encoding as MIME Q (not B) with UTF8 as default. |
# encoding as MIME Q (not B) with UTF8 as default. |
134 |
my $cleanTag= encode("MIME-Q",$sadb->get_prop($mode, "tag")); |
my $cleanTag= encode("MIME-Q",$sadb->get_prop($mode, "tag")); |
135 |
@@ -243,7 +252,7 @@ |
@@ -243,7 +267,7 @@ |
136 |
|
|
137 |
if ($newmd5 ne $md5) { |
if ($newmd5 ne $md5) { |
138 |
`expand-template /etc/mail/spamassassin/local.cf`; |
`expand-template /etc/mail/spamassassin/local.cf`; |
139 |
- `/usr/bin/systemctl restart spamassassin.service`; |
- `/etc/init.d/spamd restart`; |
140 |
+ `/etc/init.d/spamd restart`; |
+ `/usr/bin/systemctl restart spamassassin.service`; |
141 |
print "\n"; |
print "\n"; |
142 |
} |
} |
143 |
|
|