/[smeserver]/rpms/smeserver-qpsmtpd/sme10/smeserver-qpsmtpd-2.7.0-bz10289-spamcheck-fetchedmail.patch
ViewVC logotype

Contents of /rpms/smeserver-qpsmtpd/sme10/smeserver-qpsmtpd-2.7.0-bz10289-spamcheck-fetchedmail.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Tue Nov 16 23:04:55 2021 UTC (2 years, 6 months ago) by jpp
Branch: MAIN
CVS Tags: smeserver-qpsmtpd-2_7_0-13_el7_sme, smeserver-qpsmtpd-2_7_0-9_el7_sme, smeserver-qpsmtpd-2_7_0-7_el7_sme, smeserver-qpsmtpd-2_7_0-14_el7_sme, smeserver-qpsmtpd-2_7_0-8_el7_sme, smeserver-qpsmtpd-2_7_0-17_el7_sme, smeserver-qpsmtpd-2_7_0-12_el7_sme, smeserver-qpsmtpd-2_7_0-11_el7_sme, smeserver-qpsmtpd-2_7_0-16_el7_sme, smeserver-qpsmtpd-2_7_0-15_el7_sme, smeserver-qpsmtpd-2_7_0-10_el7_sme, HEAD
* Tue Nov 16 2021 Jean-Philippe Pialasse <tests@pialasse.com> 2.7.0-7.sme
- mail sent on 127.0.0.200:25 should be spam checked [SME: 10289]
  filtering again fetchmail originating mails

1 diff -Nur --no-dereference smeserver-qpsmtpd-2.7.0.old/root/etc/e-smith/templates/var/service/qpsmtpd/config/peers/local/71forcespamcheck smeserver-qpsmtpd-2.7.0/root/etc/e-smith/templates/var/service/qpsmtpd/config/peers/local/71forcespamcheck
2 --- smeserver-qpsmtpd-2.7.0.old/root/etc/e-smith/templates/var/service/qpsmtpd/config/peers/local/71forcespamcheck 1969-12-31 19:00:00.000000000 -0500
3 +++ smeserver-qpsmtpd-2.7.0/root/etc/e-smith/templates/var/service/qpsmtpd/config/peers/local/71forcespamcheck 2021-11-16 17:59:32.999000000 -0500
4 @@ -0,0 +1,39 @@
5 +{
6 +# this is based on 70spamassassin fragment
7 +# it does the same except it will force check on fetchmail inputs
8 +
9 +# You can run the spamassassin plugin with options. See perldoc
10 +# plugins/spamassassin for details.
11 +#
12 +# spamassassin
13 +# rejects mails with a SA score higher than 20 and munges the subject
14 +# of the score is higher than 10.
15 +#
16 +# spamassassin reject_threshold 20 munge_subject_threshold 10
17 +
18 + my $status = $spamassassin{status} || 'disabled';
19 + return "# spamassassin disabled" unless ($status eq "enabled");
20 +
21 + my @options = qw(forcespamcheck);
22 +
23 + if ($spamassassin{Sensitivity} eq "custom")
24 + {
25 + if ($spamassassin{RejectLevel} > $spamassassin{TagLevel})
26 + {
27 + push @options, "reject", $spamassassin{RejectLevel};
28 + }
29 + }
30 +
31 + if ($spamassassin{SubjectTag} eq "enabled")
32 + {
33 + push @options, "munge_subject_threshold", $spamassassin{TagLevel};
34 + }
35 +
36 + my $size = $spamassassin{MaxMessageSize} || '';
37 + if ($size =~ m/^\d+$/)
38 + {
39 + push @options, "size_limit", $size;
40 + }
41 +
42 + return join " ", @options;
43 +}
44 diff -Nur --no-dereference smeserver-qpsmtpd-2.7.0.old/root/usr/share/qpsmtpd/plugins/forcespamcheck smeserver-qpsmtpd-2.7.0/root/usr/share/qpsmtpd/plugins/forcespamcheck
45 --- smeserver-qpsmtpd-2.7.0.old/root/usr/share/qpsmtpd/plugins/forcespamcheck 1969-12-31 19:00:00.000000000 -0500
46 +++ smeserver-qpsmtpd-2.7.0/root/usr/share/qpsmtpd/plugins/forcespamcheck 2021-11-16 17:59:32.795000000 -0500
47 @@ -0,0 +1,61 @@
48 +#!perl -w
49 +=head1 NAME
50 +
51 +forcespamcheck - SpamAssassin integration for qpsmtpd
52 +
53 +=head1 DESCRIPTION
54 +
55 +Plugin that forces check if the mail is spam by using the "spamd" daemon
56 +from the SpamAssassin package. F<http://www.spamassassin.org>
57 +
58 +=head1 CONFIG
59 +This plugins needs spamassassin like arguments
60 +Refer to spamassassin plugin
61 +
62 +On top of that it uses a config file with an ip per line corresponding of
63 +local_ip of the qpsmtpd server on which the remote client is trying to deliver
64 +the mail. Please be cautious this is not the remote client ip !
65 +THe initial idea is to force spam check for some deamons by making them
66 +sending to 127.0.0.200:25 so other daemons trying to deliver on 127.0.0.1:25
67 +or LAN client delivering on 192.168.0.1:25 will avoid the spam check, unless you
68 +also specify those ips in forcespamcheck file.
69 +
70 +=cut
71 +
72 +use strict;
73 +use warnings;
74 +use Qpsmtpd::Constants;
75 +use Qpsmtpd::DSN;
76 +use Socket qw(:DEFAULT :crlf);
77 +use IO::Handle;
78 +
79 +sub register {
80 + my ($self, $qp, %args) = @_;
81 + $self->log(LOGERROR, "Bad parameters for the forcespamcheck plugin")
82 + if @_ % 2;
83 + #first if spamassassin already loaded return DECLINED; not to load it twice
84 + my @datahooked = $qp->hooks('data_post');
85 + for my $item (@datahooked) {
86 + $self->log(LOGNOTICE,"spamassassin aleady loaded") if $item->{name} eq "spamassassin";
87 + return DECLINED if $item->{name} eq "spamassassin";
88 + }
89 + # else we can go on
90 + my $param = join(q{ }, map{qq{$_ $args{$_}}} keys %args);
91 + my $ip = $self->qp->connection->local_ip;
92 + # read here list of ip from file; or default on 127.0.0.200
93 + my %forcespamcheck = map { $_ => 1 } $self->qp->config('forcespamcheck');
94 + # we force spamcheck on 127.0.0.200 as used by fetchmail
95 + $forcespamcheck{'127.0.0.200'} = 1;
96 + return DECLINED unless (exists $forcespamcheck{$ip});
97 + my $plugin_line = "spamassassin " . $param;
98 + my $this_plugin = $self->qp->_load_plugin($plugin_line, $self->qp->plugin_dirs);
99 + $self->register_hook('data', 'data_handler');
100 +}
101 +
102 +sub data_handler {
103 + my ($self, $transaction) = @_;
104 + my $ip = $self->qp->connection->local_ip;
105 + # logged only there to avoid double line in log in register.
106 + $self->log(LOGINFO,
107 + "forcing spamassassin check for connection on $ip");
108 +}

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed