1 |
diff -Nur smeserver-spamassassin-2.6.0/root/var/service/spamd/run smeserver-spamassassin-2.6.0_bz10137/root/var/service/spamd/run |
2 |
--- smeserver-spamassassin-2.6.0/root/var/service/spamd/run 2016-02-06 00:25:57.000000000 +0100 |
3 |
+++ smeserver-spamassassin-2.6.0_bz10137/root/var/service/spamd/run 2017-03-08 14:53:47.434583656 +0100 |
4 |
@@ -1,30 +1,23 @@ |
5 |
-#!/bin/sh |
6 |
-#---------------------------------------------------------------------- |
7 |
-# copyright (C) 1999-2003 Mitel Networks Corporation |
8 |
-# |
9 |
-# This program is free software; you can redistribute it and/or modify |
10 |
-# it under the terms of the GNU General Public License as published by |
11 |
-# the Free Software Foundation; either version 2 of the License, or |
12 |
-# (at your option) any later version. |
13 |
-# |
14 |
-# This program is distributed in the hope that it will be useful, |
15 |
-# but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
-# GNU General Public License for more details. |
18 |
-# |
19 |
-# You should have received a copy of the GNU General Public License |
20 |
-# along with this program; if not, write to the Free Software |
21 |
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
-# |
23 |
-# Technical support for this program is available from Mitel Networks |
24 |
-# Please visit our web site www.mitel.com/sme/ for details. |
25 |
-#---------------------------------------------------------------------- |
26 |
-exec 2>&1 |
27 |
+#!/usr/bin/perl -w |
28 |
|
29 |
-SPAMD_STATUS=$(/sbin/e-smith/db configuration getprop spamassassin status) |
30 |
+use strict; |
31 |
+use esmith::ConfigDB; |
32 |
|
33 |
-if [ "$SPAMD_STATUS" == "enabled" ]; then |
34 |
- exec /usr/bin/spamd -u spamd --syslog=stderr --ipv4-only |
35 |
-else |
36 |
- /usr/bin/sv d . |
37 |
-fi |
38 |
+open(STDERR, ">&STDOUT") or warn "Failed to redirect stderr to stdout: $!"; |
39 |
+my $c = esmith::ConfigDB->open_ro || die "Couldn't open the configuration database"; |
40 |
+ |
41 |
+my $spamd = $c->get('spamd'); |
42 |
+my $spamass = $c->get('spamassassin'); |
43 |
+ |
44 |
+if ( ($spamass->prop('status') || 'disabled') ne 'enabled'){ |
45 |
+ exec('/usr/bin/sv', 'd', '.'); |
46 |
+} |
47 |
+else{ |
48 |
+ my $bayes = $spamass->prop('UseBayes') || '0'; |
49 |
+ my $tell = $spamd->prop('SpamLearning') || 'disabled'; |
50 |
+ my @args = qw(-u spamd --syslog=stderr --ipv4-only); |
51 |
+ if ($bayes =~ m/^1|yes|on|enabled$/ && $tell =~ m/^1|yes|on|enabled$/){ |
52 |
+ push @args, '--allow-tell'; |
53 |
+ } |
54 |
+ exec('/usr/bin/spamd', @args); |
55 |
+} |