[clamassassin-discuss] Maildrop patch update
Juan González
juan at xdracco.net
Thu Dec 28 23:45:41 PST 2006
James,
I think my previous patch totally sucks. So, I rewrote it, staying even more
faithful to your code. Please check it out and implement it or something like
it. Clamassassin is great but is useless for Maildrop users. =)
The -r1 is simply for a Gentoo ebuild release
Thanks
******** MAILDROP PATCH **********
--- CHANGELOG.orig 2006-01-09 21:02:42.000000000 -0800
+++ CHANGELOG 2006-12-28 23:22:33.000000000 -0800
@@ -3,6 +3,11 @@
See LICENSE file for information on your legal rights to this software.
+Version 1.2.3-r1
+
+- Added Maildrop support (by Juan Gonzalez <juan_*_xdracoo_*_net>)
+- Added syslog support (by Juan Gonzalez <juan_*_xdracoo_*_net>)
+
Version 1.2.3
- Added error checking when temporary message file is made. Previously
--- README.orig 2006-01-09 21:02:42.000000000 -0800
+++ README 2006-12-28 23:22:10.000000000 -0800
@@ -1,4 +1,4 @@
-clamassassin 1.2.3
+clamassassin 1.2.3-r1
Author: James Lick <jlick-clamassassin at jameslick.com>
Website: http://jameslick.com/clamassassin/
@@ -10,6 +10,8 @@
Copyright (c) 2003-2006, James Lick
All rights reserved.
+Maildrop Patchset by Juan Gonzalez <juan_*_xdracoo_*_net>
+
See LICENSE file for information on your legal rights to this software.
clamassassin is a simple script for virus scanning an e-mail message as a
@@ -57,6 +59,8 @@
ClamAV: http://www.clamav.net/
formail (included in procmail): http://www.procmail.org/
+OR
+reformail (included in maildrop): http://www.courier-mta.org/maildrop
mktemp: http://www.mktemp.org/mktemp/
formail and mktemp are already installed on many systems, but not on some
@@ -188,6 +192,12 @@
script, so if you have to edit something manually, please send me a
suggestion to make that configurable.
+To enable support for maildrop:
+ --enable-maildrop
+ Enable Maildrop support (disables Procmail support).
+ --disable-maildrop
+ (default) Enable Procmail support (disables Maildrop support).
+
INSTALLATION:
When you are satisfied with the results, run 'make install'. In most cases
@@ -258,6 +268,23 @@
Thanks to David for supplying the sample recipe.
+MAILDROP:
+
+This script will most commonly be used as a filter in procmail. It is beyond
+the scope of this document to explain how to setup procmail, so this assumes
+that you already are familiar with it.
+
+To pass your mail through clamassassin, add the following command
to /etc/maildroprc:
+
+
+if ( /^Content-(?:Disposition|Transfer-Encoding|Type): (?:attachment|base64|
multipart)/:h )
+{
+ exception {
+ xfilter "/path/to/clamassassin"
+ }
+
+}
+
USING CLAMDSCAN:
ClamAV can do virus scanning using a client/server model. This greatly
--- clamassassin.in.orig 2006-01-09 21:02:42.000000000 -0800
+++ clamassassin.in 2006-12-28 23:16:56.000000000 -0800
@@ -50,8 +50,8 @@
# You'll want to add a trailing space before the old subject
SUBJECTHEAD="@CONF_SUBJECTHEAD@"
-# Configure your full path to formail
-FORMAIL=@CONF_FORMAIL@
+# Configure your full path to formail (Procmail) or reformail (Maildrop)
+FORMAIL="@CONF_FORMAIL@"
# Configure your full path to clamscan or clamdscan
# (If you use clamdscan, see the README for directions)
@@ -81,11 +81,23 @@
CAT=@CONF_CAT@
SED=@CONF_SED@
ECHO=@CONF_ECHO@
+LOGGER=@CONF_LOGGER@
-# END CONFIGURATION
+# Logging
+LOGGING=0
+FACILITY="mail.info"
+EFACILITY="mail.err"
+# END CONFIGURATION
# DO NOT MAKE CHANGES PAST THIS LINE
+# clamassassin version
+VERSION=1
+PATCHLEVEL=2
+SUBLEVEL=3
+EXTRAVERSION=-r1
+CLAMASSASSINVERS="clamassassin ${VERSION}.${PATCHLEVEL}.
${SUBLEVEL}${EXTRAVERSION}"
+
# Routine to cleanup and exit with an error code
bail()
{
@@ -112,7 +124,7 @@
# unfiltered intead
if [ $? != 0 ]
then
- ${FORMAIL} -f -I "X-Virus-Status: Failed" -I \
+ ${FORMAIL} "X-Virus-Status: Failed" -I \
"X-Virus-Report: Internal error mktemp ${2} failed" \
-I "X-Virus-Checker-Version: ${VERSION}"
bail $?
@@ -147,9 +159,9 @@
MINOR=`${SIGTOOL} --stdout -i ${SIGLOC}/daily.cvd \
| ${SED} -e "/^Version: /!d" -e "s/.* //"`
SIGVERS="${MAJOR}.${MINOR}"
- VERSION="@PACKAGE_STRING@ with ${CLAMVERS} signatures ${SIGVERS}"
+ VERSION="${CLAMASSASSINVERS} with ${CLAMVERS} signatures ${SIGVERS}"
else
- VERSION="@PACKAGE_STRING@ with ${CLAMVERS}"
+ VERSION="${CLAMASSASSINVERS} with ${CLAMVERS}"
fi
# Have ClamAV check the message and save the simple results in the log
@@ -164,8 +176,11 @@
if [ ${RESULT} = 0 ]
then
# Spit out the message with a header indicating it is clean
- ${FORMAIL} -f -I "X-Virus-Status: No" -I "X-Virus-Report:" \
+ ${FORMAIL} "X-Virus-Status: No" -I "X-Virus-Report:" \
-I "X-Virus-Checker-Version: ${VERSION}" < ${MSGTMP}
+ if [ ${LOGGING} == 1 ] ; then
+ ${LOGGER} -i -p ${FACILITY} -t clamd clamd: clean message
+ fi
bailiferr $?
else
# If the result is 1, then a virus was detected
@@ -176,19 +191,26 @@
REASON=`${SED} -e 's/[^:]*: //' -e '/ FOUND$/!d' \
-e 's/ FOUND$/ FOUND /' < ${LOGTMP} | ${SED} -n -e 'H;${x;s/\n//g;p;}'`
# Extract the subject so it can be modified if SUBJECTHEAD is set
- # Note that some versions of formail will add a leading space to the
- # subject line, so we strip off one leading space if present.
+ # Note that some versions of reformail/formail will add a leading
+ # space to the subject line, so we strip off one leading space
+ # if present.
SUBJECT=`${FORMAIL} -c -x "Subject:" < ${MSGTMP} | ${SED} -e "s/^ //"`
# Spit out the message with the headers showing it is infected and how
- ${FORMAIL} -f -I "Subject: ${SUBJECTHEAD}${SUBJECT}" \
+ ${FORMAIL} "Subject: ${SUBJECTHEAD}${SUBJECT}" \
-I "X-Virus-Status: Yes" -I "X-Virus-Report: ${REASON}" \
-I "X-Virus-Checker-Version: ${VERSION}" < ${MSGTMP}
+ if [ ${LOGGING} == 1 ] ; then
+ ${LOGGER} -i -p ${FACILITY} -t clamd stream: ${REASON} FOUND
+ fi
bailiferr $?
else
# If the result was not 0 or 1 then some sort of error occured
- ${FORMAIL} -f -I "X-Virus-Status: Failed" -I \
+ ${FORMAIL} "X-Virus-Status: Failed" -I \
"X-Virus-Report: ${CLAMSCAN} error ${RESULT}" \
-I "X-Virus-Checker-Version: ${VERSION}" < ${MSGTMP}
+ if [ ${LOGGING} == 1 ] ; then
+ ${LOGGER} -i -p ${EFACILITY} -t clamd error ${RESULT}
+ fi
bailiferr $?
fi
fi
--- configure.orig 2006-01-09 21:02:42.000000000 -0800
+++ configure 2006-12-28 22:14:08.000000000 -0800
@@ -274,7 +274,7 @@
PACKAGE_STRING='clamassassin 1.2.3'
PACKAGE_BUGREPORT='jlick-clamassassin at jameslick.com'
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME
PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix
program_transform_name bindir sbindir libexecdir datadir sysconfdir
sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir
build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CONF_RM
CONF_CAT CONF_SED CONF_ECHO CONF_FORMAIL CONF_MKTEMP CONF_SIGTOOL
CONF_CLAMSCAN CONF_CLAMSCANNER CONF_CLAMDSCAN CONF_SIGVERSFLAG
CONF_ADDSCANNERFLAG CONF_CLAMSCANOPT CONF_SIGLOC CONF_TMP CONF_SUBJECTHEAD
LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME
PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix
program_transform_name bindir sbindir libexecdir datadir sysconfdir
sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir
build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CONF_RM
CONF_CAT CONF_SED CONF_ECHO CONF_FORMAIL CONF_REFORMAIL CONF_MKTEMP
CONF_SIGTOOL CONF_CLAMSCAN CONF_CLAMSCANNER CONF_CLAMDSCAN CONF_SIGVERSFLAG
CONF_ADDSCANNERFLAG CONF_CLAMSCANOPT CONF_SIGLOC CONF_TMP CONF_LOGGER
CONF_SUBJECTHEAD LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -787,6 +787,10 @@
Optional Features:
--disable-FEATURE do not include FEATURE (same
as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --enable-maildrop
+ Enable Maildrop support (disables Procmail support).
+ --disable-maildrop
+ (default) Enable Procmail support (disables Maildrop support).
--enable-clamdscan
Force clamassassin to use clamdscan even if /tmp/clamd not found.
--disable-clamdscan
@@ -1399,6 +1403,53 @@
{ (exit 1); exit 1; }; }
fi
+
+# Extract the first word of "sed", so it can be a program name with args.
+set dummy sed; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_CONF_SED+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $CONF_SED in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_CONF_SED="$CONF_SED" # Let the user override the test with a
path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_CONF_SED="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ ;;
+esac
+fi
+CONF_SED=$ac_cv_path_CONF_SED
+
+if test -n "$CONF_SED"; then
+ echo "$as_me:$LINENO: result: $CONF_SED" >&5
+echo "${ECHO_T}$CONF_SED" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+if test "$CONF_SED" = ""
+then
+ { { echo "$as_me:$LINENO: error: Required utility sed not found." >&5
+echo "$as_me: error: Required utility sed not found." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
# Extract the first word of "echo", so it can be a program name with args.
set dummy echo; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
@@ -1445,16 +1496,16 @@
{ (exit 1); exit 1; }; }
fi
-# Extract the first word of "formail", so it can be a program name with args.
-set dummy formail; ac_word=$2
+# Extract the first word of "logger", so it can be a program name with args.
+set dummy logger; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_path_CONF_FORMAIL+set}" = set; then
+if test "${ac_cv_path_CONF_LOGGER+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- case $CONF_FORMAIL in
+ case $CONF_LOGGER in
[\\/]* | ?:[\\/]*)
- ac_cv_path_CONF_FORMAIL="$CONF_FORMAIL" # Let the user override the test
with a path.
+ ac_cv_path_CONF_LOGGER="$CONF_LOGGER" # Let the user override the test with
a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -1464,7 +1515,7 @@
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_path_CONF_FORMAIL="$as_dir/$ac_word$ac_exec_ext"
+ ac_cv_path_CONF_LOGGER="$as_dir/$ac_word$ac_exec_ext"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
@@ -1474,21 +1525,100 @@
;;
esac
fi
-CONF_FORMAIL=$ac_cv_path_CONF_FORMAIL
+CONF_LOGGER=$ac_cv_path_CONF_LOGGER
-if test -n "$CONF_FORMAIL"; then
- echo "$as_me:$LINENO: result: $CONF_FORMAIL" >&5
-echo "${ECHO_T}$CONF_FORMAIL" >&6
+if test -n "$CONF_LOGGER"; then
+ echo "$as_me:$LINENO: result: $CONF_LOGGER" >&5
+echo "${ECHO_T}$CONF_LOGGER" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
+# Check whether --enable-maildrop or --disable-maildrop was given.
+if test "${enable_maildrop+set}" = set; then
+ MAILDROP=1
+ MDA="Maildrop"
+ # Extract the first word of "reformail", so it can be a program name with
args.
+ set dummy reformail; ac_word=$2
+ echo "$as_me:$LINENO: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_path_CONF_REFORMAIL+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ case $CONF_REFORMAIL in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_CONF_FORMAIL="$CONF_REFORMAIL" # Let the user override the
test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+ for as_dir in $PATH ; do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_CONF_REFORMAIL="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+ done
+ done
+ ;;
+ esac
+ fi
+ CONF_FORMAIL="$ac_cv_path_CONF_REFORMAIL"
+else
+ MAILDROP=0
+ MDA="Procmail"
+ # Extract the first word of "formail", so it can be a program name with
args.
+ set dummy formail; ac_word=$2
+ echo "$as_me:$LINENO: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_path_CONF_FORMAIL+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ case $CONF_FORMAIL in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_CONF_FORMAIL="$CONF_FORMAIL" # Let the user override the test
with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+ for as_dir in $PATH ; do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_CONF_FORMAIL="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+ done
+ done
+ ;;
+ esac
+ fi
+ CONF_FORMAIL="$ac_cv_path_CONF_FORMAIL"
+fi
+
+if test -n "$CONF_FORMAIL"; then
+ echo "$as_me:$LINENO: result: $CONF_FORMAIL" >&5
+ echo "${ECHO_T}$CONF_FORMAIL" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+ echo "${ECHO_T}no" >&6
+fi
+
if test "$CONF_FORMAIL" = ""
then
- { { echo "$as_me:$LINENO: error: Required utility formail not found." >&5
-echo "$as_me: error: Required utility formail not found." >&2;}
- { (exit 1); exit 1; }; }
+ { { echo "$as_me:$LINENO: error: Required utility formail not found." >&5
+ echo "$as_me: error: Required utility formail (part of Procmail) not found."
>&2;}
+ { (exit 1); exit 1; }; }
+else
+ if [ "$MAILDROP" == 1 ] ; then
+ CONF_FORMAIL="${CONF_FORMAIL} -I"
+ else
+ CONF_FORMAIL="${CONF_FORMAIL} -f -I"
+ fi
fi
# Extract the first word of "mktemp", so it can be a program name with args.
@@ -1744,6 +1874,9 @@
fi;
+{ echo "$as_me:$LINENO: Using ${MDA} mail delivery agent" >&5
+echo "$as_me: Using ${MDA} mail delivery agent" >&6;}
+
if test "${DO_VERSION_CHECK}" = "yes"
then
@@ -1812,6 +1945,8 @@
fi
+
+
{ echo "$as_me:$LINENO: Using scanner ${CONF_CLAMSCANNER}" >&5
echo "$as_me: Using scanner ${CONF_CLAMSCANNER}" >&6;}
@@ -2568,6 +2703,7 @@
s, at CONF_SED@,$CONF_SED,;t t
s, at CONF_ECHO@,$CONF_ECHO,;t t
s, at CONF_FORMAIL@,$CONF_FORMAIL,;t t
+s, at CONF_LOGGER@,$CONF_LOGGER,;t t
s, at CONF_MKTEMP@,$CONF_MKTEMP,;t t
s, at CONF_SIGTOOL@,$CONF_SIGTOOL,;t t
s, at CONF_CLAMSCAN@,$CONF_CLAMSCAN,;t t
@@ -2848,4 +2984,3 @@
# would make configure fail if this is the last instruction.
$ac_cs_success || { (exit 1); exit 1; }
fi
-
--- configure.ac.orig 2006-01-09 21:02:42.000000000 -0800
+++ configure.ac 2006-12-28 22:16:14.000000000 -0800
@@ -28,10 +28,13 @@
AC_MSG_ERROR([Required utility echo not found.])
fi
+AC_PATH_PROG(CONF_LOGGER, logger)
+
AC_PATH_PROG(CONF_FORMAIL, formail)
+AC_PATH_PROG(CONF_REFORMAIL, reformail)
if test "$CONF_FORMAIL" = ""
then
- AC_MSG_ERROR([Required utility formail not found.])
+ AC_MSG_ERROR([Required utility formail/reformail not found.])
fi
AC_PATH_PROG(CONF_MKTEMP, mktemp)
More information about the clamassassin-discuss
mailing list