From 987296a53ca15ee06f407d89379828e0dc2dfebd Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 24 Apr 2012 19:21:15 +0200 Subject: [PATCH] Add the possibility to put contacts in whitelist --- ipasserelle-groupware.spec | 7 ++++-- root/etc/e-smith/cron.daily/sogo_whitelist | 29 ++++++++++++++++++++++ .../locale/fr/etc/e-smith/web/functions/sogo | 8 ++++++ .../mail/spamassassin/local.cf/80sogo_whitelist | 12 +++++++++ root/etc/e-smith/web/functions/sogo | 6 +++++ .../site_perl/esmith/FormMagick/Panel/sogo.pm | 1 + 6 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 root/etc/e-smith/cron.daily/sogo_whitelist create mode 100644 root/etc/e-smith/templates/etc/mail/spamassassin/local.cf/80sogo_whitelist diff --git a/ipasserelle-groupware.spec b/ipasserelle-groupware.spec index 7fbb668..03b070d 100644 --- a/ipasserelle-groupware.spec +++ b/ipasserelle-groupware.spec @@ -1,6 +1,6 @@ -%define version 0.2.0 -%define release 1 +%define version 0.2.1 +%define release 1.beta0 %define name ipasserelle-groupware Name: %{name} @@ -33,6 +33,9 @@ Based on smeserver-sogo from nethesis %changelog +* Tue Apr 24 2012 Daniel Berteaud - 0.2.1-1.sme +- Add the possibility to put contacts in whitelist + * Wed Mar 14 2012 Daniel Berteaud - 0.2.0-1.sme - Migrate to git diff --git a/root/etc/e-smith/cron.daily/sogo_whitelist b/root/etc/e-smith/cron.daily/sogo_whitelist new file mode 100644 index 0000000..5c9a745 --- /dev/null +++ b/root/etc/e-smith/cron.daily/sogo_whitelist @@ -0,0 +1,29 @@ +#!/bin/bash + +HOME=/root + +SOGOWL=$(/sbin/e-smith/db/configuration getprop sogod AutoWhiteList || $(echo no)) + +if [ "$SOGOWL" != 'yes' ]; then + exit 0 +fi + +/usr/bin/mysql <<'EOF' | grep -iE "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$" | sed -e 's/^/whitelist_from /' > /etc/mail/spamassassin/sogo_whitelist +connect sogo; +SELECT CONCAT( + 'SELECT * FROM (SELECT c_mail FROM ', + GROUP_CONCAT(tb SEPARATOR ' UNION SELECT c_mail FROM '), + ') AS emails ORDER BY c_mail' +) +INTO @mailquery FROM +( +SELECT TABLE_NAME tb +FROM INFORMATION_SCHEMA.COLUMNS +WHERE column_name LIKE 'c_mail' +AND TABLE_SCHEMA='sogo' +) AS tbls; +PREPARE stmt FROM @mailquery; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +EOF + diff --git a/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/sogo b/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/sogo index 8391aa4..911623a 100644 --- a/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/sogo +++ b/root/etc/e-smith/locale/fr/etc/e-smith/web/functions/sogo @@ -59,4 +59,12 @@ ALLOWED_OR_NOT Autorisé ? + + AUTO_WL_DESC + Cette option permet de mettre automatiquement tous les contacts dans une liste blanche, afin queleur mails ne soient jamais considérés comme spam + + + AUTO_WL + Liste blanche automatique + diff --git a/root/etc/e-smith/templates/etc/mail/spamassassin/local.cf/80sogo_whitelist b/root/etc/e-smith/templates/etc/mail/spamassassin/local.cf/80sogo_whitelist new file mode 100644 index 0000000..c2df56a --- /dev/null +++ b/root/etc/e-smith/templates/etc/mail/spamassassin/local.cf/80sogo_whitelist @@ -0,0 +1,12 @@ +{ + +my $sogowl = $sogod{'AutoWhiteList'} || 'no'; + +if ($sogowl eq 'yes'){ + $OUT .= 'include sogo_whitelist'; +} +else{ + $OUT .= ''; +} + +} diff --git a/root/etc/e-smith/web/functions/sogo b/root/etc/e-smith/web/functions/sogo index 897a274..8f12c38 100644 --- a/root/etc/e-smith/web/functions/sogo +++ b/root/etc/e-smith/web/functions/sogo @@ -65,6 +65,12 @@ __DATA__ PUBLIC_ACCESS_DESC + + AUTO_WL_DESC + + ALLOWED_GROUPS_DESC diff --git a/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/sogo.pm b/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/sogo.pm index a8fe0d5..1e8791b 100644 --- a/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/sogo.pm +++ b/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/sogo.pm @@ -110,6 +110,7 @@ sub apply { $configdb->set_prop('sogod', 'EMailAlarms', $q->param("mailAlarm")); $configdb->set_prop('sogod', 'AuxiliaryUserAccounts', $q->param("auxAccounts")); $configdb->set_prop('sogod', 'PublicAccess', $q->param("publicAccess")); + $configdb->set_prop('sogod', 'AutoWhiteList', $q->param("autoWhiteList")); $configdb->set_prop('sogod', 'AllowedGroups', join(',', $q->param("allowedGroups"))); unless ( system ("/sbin/e-smith/signal-event", "email-update") == 0 ){