Hugo Monteiro wrote:
Hello all, and Johannes if you're around,
I was trying to set up the "new" antispam plugin with the mailtrain backend, and i was trying to use the sendmail binary that's part of a qmail system. The message wouldn't get sent and i kept getting exit error 100 from the /var/qmail/bin/sendmail binary. To try to figure out what was happening, i mean a fake sendmail program, which is nothing more than a bash script to capture the command call input.
The script is rather simple, it just places the calling parameters into a txt file and the stdin into another.
code is
#!/bin/bash
echo $* > /tmp/sendmail-parms.txt exec cat<&0 >> /tmp/sendmail-msg.txt
exit 0
So i tried a retrain and went to see what those txt files had. The parms.txt file was fine apparently, with cat /tmp/sendmail-parms.txt i got
-f hm@hmonteiro.net notspam-hm@hmonteiro.net
Then i did the same to the message file, with cat /tmp/sendmail-msg.txt, and i got the follwing
Return-Path: <hugo.monteiro@fct.unl.pt>Delivered-To: hm@hmonteiro.net Received: (qmail 21616 invoked from network); 19 Apr 2008 16:21:17 -0000 Received: (simscan 1.4.1 ppid 21609 pid 21611 t 0.1451s) (scanners: regex: 1.4.1 attach: 1.4.1 clamav: 0.92.1 /m:46/d:6803); 19 Apr 0108 16:21:17 -0000 Received: from femme-fatal.resnet.costabasto.com (HELO femme-fatal) (192.168.0.20) by hmonteiro.net with SMTP; 19 Apr 2008 16:21:17 -0000 Subject: buy some viagra HURRAY X-DSPAM-Result: Innocent X-DSPAM-Processed: Sat Apr 19 17:21:17 2008 X-DSPAM-Confidence: 0.4945 X-DSPAM-Probability: 0.0330 X-DSPAM-Signature: 480a1bfd216125429498786
viagra sale really HURRAY cheap! only $5!
As you can see, there is no new line in the first line. Return-Path and Delivered-To are set in a single line, which makes qmail-inject (which is later used by /var/qmail/bin/sendmail) to abort like this
cat /tmp/sendmail-msg.txt | /var/qmail/bin/sendmail -f hm@hmonteiro.net notspam-hm@hmonteiro.net qmail-inject: fatal: unable to parse this line: Return-Path: <hugo.monteiro@fct.unl.pt>Delivered-To: hm@hmonteiro.net
Before i go into digging the plugin code i was wondering if i'm not seing things clearly and thinking this is in fact a bug in the plugin code.
Thank you all in advance,
Hugo Monteiro.
I've managed to get it working with the following patch. There may be a better way, deeper in the code, to do it. Timo or Johannes ... any sugestions? --- dovecot-antispam/mailtrain.c 2008-04-19 22:20:32.000000000 +0100 +++ dovecot-antispam-qmail/mailtrain.c 2008-04-19 22:25:45.000000000 +0100 @@ -274,7 +274,8 @@ mail_storage_set_error(t->box->storage, "Failed to write line to temp"); goto failed_to_copy; - } + } else + o_stream_send_str(outstream, "\n"); if (o_stream_send_istream(outstream, mailstream) < 0) { ret = -1; Cheers, Hugo Monteiro. -- ci.fct.unl.pt:~# cat .signature Hugo Monteiro Email : hugo.monteiro@fct.unl.pt Telefone : +351 212948300 Ext.15307 Centro de Informática Faculdade de Ciências e Tecnologia da Universidade Nova de Lisboa Quinta da Torre 2829-516 Caparica Portugal Telefone: +351 212948596 Fax: +351 212948548 www.ci.fct.unl.pt apoio@fct.unl.pt ci.fct.unl.pt:~# _