Hello everyone,

I'm using a mail server that integrates with spamassassin, by passing
the messages from the queue to the spamd daemon via the socket
(default 127.0.0.1:783) and takes various actions using spamd's
response.
Everything worked flawlessly for 99.99% of scanned messages, now some
messages cannot be scanned and spamd returns:

Sep 13 11:30:09 k9 spamd[27231]: spamd: timeout: (300 second timeout
while trying to CHECK) at /usr/bin/spamd line 2000, <GEN82> line 84.

I'm using spamassassin 3.2.3 (latest version) and the following lines
are being sent over socket:

'CHECK SPAMC/1.2\r\nContent-length: %d\r\n\r\n', size
and then the raw rfc822 message follows. The content-length size is
calculated correctly, so this cannot be the problem, otherwise spamd
would have returned an error regarding different content lengths.
Shortly, the algorithm is:
socket.send
socket.recv

After digging a while more deeply, I have found out that the spamc
client, after sending the message, shuts down writing on the socket
and spamd responds immediately. I did the same and it worked. In this
case the algo is:
socket.send
socket.shutdown(write)
socket.recv


My questions are:
- Why does it work for 99.99% of messages without having to shutdown
writing on socket
- Why doesn't it work with that message?
- If spamd depends on this shutdown, isn't the Content-length
specification redundant?

Here's an email that gets timed out when scanning:

$ ./send_message.py test-notok.eml
SPAMD/1.0 79 Timeout: (300 second timeout while trying to CHECK)

I have attached the python script as well as the test-notok.eml message.

Thanks in advance!

Regards,
Alin.
#!/usr/bin/python

import socket, sys;

shutdownSocket=False;
if sys.argv[1]=='-s':
  shutdownSocket=True;
  sys.argv.remove(sys.argv[1]);

f=open(sys.argv[1], 'rb');
mailstream='';
for l in f:
  mailstream+=l;
f.close();
size=len(mailstream);

s=socket.socket(socket.AF_INET, socket.SOCK_STREAM);
s.connect(('127.0.0.1', 783));
s.send('CHECK SPAMC/1.2\r\nContent-length: %d\r\n\r\n' % size);
s.send(mailstream);
if shutdownSocket:
  s.shutdown(1)
print s.recv(1024), s.recv(1024);
Received: by example.org (Axigen sendmail invoked by uid 0) id 2E2EED; Tue, 11
 Sep 2007 05:09:29 +0200
Date: Tue, 11 Sep 2007 05:09:29 +0200
To: test recipient
From: test sender
Subject: test
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="iso-8859-1"

test

Reply via email to