unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 3/3] scripts/dc-dlvr: ClamAV support via clamdscan
Date: Fri, 17 Jun 2016 00:44:18 +0000	[thread overview]
Message-ID: <20160617004418.2182-4-e@80x24.org> (raw)
In-Reply-To: <20160617004418.2182-1-e@80x24.org>

SpamAssassin often misses messages which contain viruses,
so ClamAV should fill that gap nicely.
---
 scripts/dc-dlvr | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/scripts/dc-dlvr b/scripts/dc-dlvr
index 2f82ff2..5ebca3f 100755
--- a/scripts/dc-dlvr
+++ b/scripts/dc-dlvr
@@ -4,6 +4,7 @@
 # This is installed as /etc/dc-dcvr on my system
 # to use with postfix main.cf: mailbox_command = /etc/dc-dlvr "$EXTENSION"
 DELIVER=/usr/lib/dovecot/deliver
+CLAMDSCAN=clamdscan
 
 # change if your spamc/spamd listens elsewhere
 spamc='spamc'
@@ -17,19 +18,27 @@ trainham,) exec $spamc -L ham > /dev/null 2>&1 ;;
 esac
 
 TMPMSG=$(mktemp -t dc-dlvr.orig.$USER.XXXXXX || exit 1)
-rm_list=$TMPMSG
+CDMSG=$(mktemp -t dc-dlvr.orig.$USER.XXXXXX || exit 1)
+rm_list="$TMPMSG $CDMSG"
+
+cat >$CDMSG
+$CLAMDSCAN --quiet - <$CDMSG
+if test $? -eq 1
+then
+	exec $DELIVER -m INBOX.spam <$CDMSG
+fi
 
 # pre-filter, for infrequently read lists which do their own spam filtering:
 if test -r ~/.dc-dlvr.pre
 then
 	set -e
-	cat > $TMPMSG
+	mv -f $CDMSG $TMPMSG
 	DEFAULT_INBOX=$(. ~/.dc-dlvr.pre)
 	case $DEFAULT_INBOX in
 	'') exec rm -f $rm_list ;;
 	INBOX) ;; # do nothing
 	*)
-		$DELIVER -m $DEFAULT_INBOX < $TMPMSG
+		$DELIVER -m $DEFAULT_INBOX <$TMPMSG
 		exec rm -f $rm_list
 		;;
 	esac
@@ -37,9 +46,9 @@ then
 	rm_list="$rm_list $PREMSG"
 	set +e
 	mv -f $TMPMSG $PREMSG
-	$spamc -E --headers < $PREMSG > $TMPMSG
+	$spamc -E --headers <$PREMSG >$TMPMSG
 else
-	$spamc -E --headers > $TMPMSG
+	$spamc -E --headers <$CDMSG >$TMPMSG
 fi
 err=$?
 

      parent reply	other threads:[~2016-06-17  0:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-17  0:44 [PATCH 0/3] dc-dlvr updates Eric Wong
2016-06-17  0:44 ` [PATCH 1/3] scripts/dc-dlvr: update copyright Eric Wong
2016-06-17  0:44 ` [PATCH 2/3] scripts/dc-dlvr: remove catchall account Eric Wong
2016-06-17  0:44 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160617004418.2182-4-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).