From ae8db08bdfeaf788beeb877cda6d1e2faf9930b6 Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Sat, 21 Aug 2021 17:10:37 +0200 Subject: [PATCH 1/2] Ensure that we don't do multiple DNS lookups in the sieve script --- core/dovecot/conf/ham.script | 13 ++++++++++--- core/dovecot/conf/spam.script | 14 +++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/core/dovecot/conf/ham.script b/core/dovecot/conf/ham.script index aa25cefb..d34abd5a 100755 --- a/core/dovecot/conf/ham.script +++ b/core/dovecot/conf/ham.script @@ -1,5 +1,12 @@ #!/bin/bash -tee >(rspamc -h {{ ANTISPAM_WEBUI_ADDRESS }} -P mailu learn_ham /dev/stdin) \ - >(rspamc -h {{ ANTISPAM_WEBUI_ADDRESS }} -P mailu -f 11 fuzzy_del /dev/stdin) \ - | rspamc -h {{ ANTISPAM_WEBUI_ADDRESS }} -P mailu -f 13 fuzzy_add /dev/stdin +RSPAMD_HOST="$(getent hosts {{ ANTISPAM_WEBUI_ADDRESS }})" +if [[ $? -ne 0 ]] +then + echo "Failed to lookup {{ ANTISPAM_WEBUI_ADDRESS }}" >&2 + exit 1 +fi + +tee >(rspamc -h $RSPAMD_HOST -P mailu learn_ham /dev/stdin) \ + >(rspamc -h $RSPAMD_HOST -P mailu -f 11 fuzzy_del /dev/stdin) \ + | rspamc -h $RSPAMD_HOST -P mailu -f 13 fuzzy_add /dev/stdin diff --git a/core/dovecot/conf/spam.script b/core/dovecot/conf/spam.script index 05a3832d..6dbb96eb 100755 --- a/core/dovecot/conf/spam.script +++ b/core/dovecot/conf/spam.script @@ -1,5 +1,13 @@ #!/bin/bash -tee >(rspamc -h {{ ANTISPAM_WEBUI_ADDRESS }} -P mailu learn_spam /dev/stdin) \ - >(rspamc -h {{ ANTISPAM_WEBUI_ADDRESS }} -P mailu -f 13 fuzzy_del /dev/stdin) \ - | rspamc -h {{ ANTISPAM_WEBUI_ADDRESS }} -P mailu -f 11 fuzzy_add /dev/stdin +RSPAMD_HOST="$(getent hosts {{ ANTISPAM_WEBUI_ADDRESS }})" +if [[ $? -ne 0 ]] +then + echo "Failed to lookup {{ ANTISPAM_WEBUI_ADDRESS }}" >&2 + exit 1 +fi + + +tee >(rspamc -h $RSPAMD_HOST -P mailu learn_spam /dev/stdin) \ + >(rspamc -h $RSPAMD_HOST -P mailu -f 13 fuzzy_del /dev/stdin) \ + | rspamc -h $RSPAMD_HOST -P mailu -f 11 fuzzy_add /dev/stdin From 368b40b4fd3c16a351aac8c127a1e878d993c399 Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Tue, 24 Aug 2021 09:24:14 +0200 Subject: [PATCH 2/2] doh --- core/dovecot/conf/ham.script | 2 +- core/dovecot/conf/spam.script | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/dovecot/conf/ham.script b/core/dovecot/conf/ham.script index d34abd5a..910df8e4 100755 --- a/core/dovecot/conf/ham.script +++ b/core/dovecot/conf/ham.script @@ -1,6 +1,6 @@ #!/bin/bash -RSPAMD_HOST="$(getent hosts {{ ANTISPAM_WEBUI_ADDRESS }})" +RSPAMD_HOST="$(getent hosts {{ ANTISPAM_WEBUI_ADDRESS }}|cut -d\ -f1)" if [[ $? -ne 0 ]] then echo "Failed to lookup {{ ANTISPAM_WEBUI_ADDRESS }}" >&2 diff --git a/core/dovecot/conf/spam.script b/core/dovecot/conf/spam.script index 6dbb96eb..e7d20427 100755 --- a/core/dovecot/conf/spam.script +++ b/core/dovecot/conf/spam.script @@ -1,6 +1,6 @@ #!/bin/bash -RSPAMD_HOST="$(getent hosts {{ ANTISPAM_WEBUI_ADDRESS }})" +RSPAMD_HOST="$(getent hosts {{ ANTISPAM_WEBUI_ADDRESS }}|cut -d\ -f1)" if [[ $? -ne 0 ]] then echo "Failed to lookup {{ ANTISPAM_WEBUI_ADDRESS }}" >&2