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