Jason Axley skrev, on 05-02-2008 07:44:
Excellent! Thanks for some more eyes on this. I'll take a look over
the next couple days. I think what he is seeing is the underlying bug
that is causing NULL to be passed to the driver for the group name from
the CTX. The patch I provided fixes some of the logic to not fail
entirely; previously the getpwnam() call probably returned NULL so the
whole thing blew up. At least now you get some useful information.
Tony -- what is your retraining mail config that results in those args
passed to dspam?
I run a cron job every so often that goes something like what's attached
- that's for my test machine where people have Maildir in their $HOME
directories; on my production machines Maildir is in a dedicated
/home/vmail/$OU/$UID hierarchy.
Best,
--Tonni
--
Tony Earnshaw
Email: tonni at hetnet dot nl
#!/bin/sh
# Reclassification script for dspam 3.0.0
# For Postfix 2.1.3 and local(8) where users have mail in ~/Maildir
#set -x
# Make a list of local users
for uid in `/usr/bin/ldapsearch2.3 -x -b "ou=groups,dc=billy,dc=demon,dc=nl" -s
sub -LLL uid | awk -F: '/uid:/ { print $2 }'`;do
# If the user has a "dspam-misclassified" dspam directory ...
if [ -d /u/home/$uid/Maildir/.dspam-misclassified ]; then
cd /u/home/$uid/Maildir/.dspam-misclassified/cur
# Cycle through the mail in the directory
for misclass in `ls`; do
# Message has no dspam header
if ! grep -i "X-DSPAM" $misclass > /dev/null 2>&1 ; then
# If the directory "processed" exists, move the message -
# otherwise, message stays in current directory
if [ -d /u/home/$uid/Maildir/.dspam-processed ]; then
cp -pa $misclass /u/home/$uid/Maildir/.dspam-processed/cur >
/dev/null 2>&1
chown $uid /u/home/$uid/Maildir/.dspam-processed/cur/$misclass
rm -f $misclass > /dev/null 2>&1
fi
fi
# dspam did not operate correctly, the message has an empty
X-DSPAM-Signature:
# header - don't operate on it :(
if ! awk '/X-DSPAM-Signature:/ { print $2 }' $misclass > /dev/null 2>&1;
then
if [ -d /u/home/$uid/Maildir/.dspam-processed ]; then
cp -pa $misclass /u/home/$uid/Maildir/.dspam-processed/cur >
/dev/null 2>&1
chown $uid /u/home/$uid/Maildir/.dspam-processed/cur/$misclass
rm -f $misclass > /dev/null 2>&1
fi
fi
# dspam header has already been modified by a previous dspam-cron action
if grep X-DSPAM-Reclassified: $misclass > /dev/null 2>&1 ; then
if [ -d /u/home/$uid/Maildir/.dspam-processed ]; then
cp -pa $misclass /u/home/$uid/Maildir/.dspam-processed/cur >
/dev/null 2>&1
chown $uid /u/home/$uid/Maildir/.dspam-processed/cur/$misclass
rm -f $misclass > /dev/null 2>&1
fi
fi
# Innocent misclassed
if grep -i "X-DSPAM-Result: Innocent" $misclass > /dev/null 2>&1 ; then
#perl -lane 'print unless m/Delivered-To/' $misclass > tmpfile
#mv tmpfile $misclass
# If the directory "processed" exists, first copy -
# message will be removed
#mail=`cat $misclass | awk '/Delivered-To:/ { print $2 }'|head -n 1`
mail="leerlingen"
#mail="tru.leerlingen"
#/usr/bin/dspam --class=spam --source=error --mode=unlearn
--deliver=spam --user $mail < $misclass > /dev/null 2>&1
/usr/bin/dspam --class=spam --source=error --deliver=spam --user
$mail < $misclass > /dev/null 2>&1
sed -i 's/X-DSPAM-Result: Innocent/X-DSPAM-Reclassified-As: Spam/'
$misclass > /dev/null 2>&1
sed -i -r 's/Subject:[[:space:]]+\[dspam\]+/Subject:/' $misclass >
/dev/null 2>&1
if [ -d /u/home/$uid/Maildir/.dspam-processed ]; then
cp -pa $misclass /u/home/$uid/Maildir/.dspam-processed/cur >
/dev/null 2>&1
chown $uid /u/home/$uid/Maildir/.dspam-processed/cur/$misclass >
/dev/null 2>&1
rm -f $misclass > /dev/null 2>&1
fi
fi
# Spam misclassed - do not use 'elif' here ;)
if grep -i "X-DSPAM-Result: Spam" $misclass > /dev/null 2>&1 ; then
# If the directory "processed" exists, first copy -
# message will be removed
#mail=`cat $misclass | awk '/Delivered-To:/ { print $2 }'|head -n 1`
mail="leerlingen"
#mail="tru.leerlingen"
#/usr/bin/dspam --class=innocent --source=error --mode=unlearn
--deliver=innocent --user $mail < $misclass > /dev/null 2>&1
/usr/bin/dspam --class=innocent --source=error --deliver=innocent
--user $mail < $misclass > /dev/null 2>&1
sed -i 's/X-DSPAM-Result: Spam/X-DSPAM-Reclassified-As: Innocent/'
$misclass
sed -i -r 's/Subject:[[:space:]]+\[dspam\]+/Subject:/' $misclass
if [ -d /u/home/$uid/Maildir/.dspam-processed ]; then
cp -pa $misclass /u/home/$uid/Maildir/.dspam-processed/cur >
/dev/null 2>&1
chown $uid /u/home/$uid/Maildir/.dspam-processed/cur/$misclass
rm -f $misclass > /dev/null 2>&1
fi
fi
done
# Remove any remaining reclassified messages, since the old ones will
# otherwise be kept until an MUA expunge has been effected
rm -f * > /dev/null 2>&1
fi
done