git » chasquid » commit 4eaf5b3

hooks: Use chasquid-rspamd if available

author Alberto Bertogli
2021-07-08 09:18:56 UTC
committer Alberto Bertogli
2021-07-08 09:18:56 UTC
parent 8f1f943fca1368532be8ee876442db2de1dc676d

hooks: Use chasquid-rspamd if available

The chasquid-rspamd utility (https://github.com/Thor77/chasquid-rspamd)
provides a better integration with rspamd, by taking envelope and
connection information from the environment variables, and communicating
with rspamd using its protocol.

So if it is available, use it instead of rspamc in the default hook.

etc/chasquid/hooks/post-data +8 -2

diff --git a/etc/chasquid/hooks/post-data b/etc/chasquid/hooks/post-data
index ef23de6..6f4fee5 100755
--- a/etc/chasquid/hooks/post-data
+++ b/etc/chasquid/hooks/post-data
@@ -5,7 +5,7 @@
 #
 #  - greylist (from greylistd) to do greylisting.
 #  - spamc (from Spamassassin) to filter spam.
-#  - rspamc (from rspamd) to filter spam.
+#  - rspamc (from rspamd) or chasquid-rspamd to filter spam.
 #  - clamdscan (from ClamAV) to filter virus.
 #  - dkimsign (from driusan/dkim) to do DKIM signing.
 #
@@ -47,7 +47,13 @@ if command -v spamc >/dev/null; then
 fi
 
 
-if command -v rspamc >/dev/null; then
+# Spam filter through rspamd.
+#
+# Use chasquid-rspamd (from https://github.com/Thor77/chasquid-rspamd) if
+# available, otherwise fall back to rspamc.
+if command -v chasquid-rspamd >/dev/null; then
+	chasquid-rspamd < "$TF" 2>/dev/null
+elif command -v rspamc >/dev/null; then
 	# Note the actions emitted by rspamc come from the thresholds
 	# configured in /etc/rspamd/actions.conf.
 	# The ones handled here are common defaults, but they might require