[Dovecot] building a simple antispam plugin
Hello,
I'm trying to build another antispam plugin, but some things are a bit unclear.
In backend_handle_mail I put store the signature returned from signature_extract into my antispam_transaction_context. In backend_commit it appears that the signature is empty. (It wasn't in backend_handle_mail).
Somehow between backend_handle_mail en backend_commit it has been cleared... When I use i_strdup it appears to work. Anyone can tell me where this clearing happens? Is i_strdup the right way to do it then?
Thanks, Alexander
Hi,
I'm trying to build another antispam plugin, but some things are a bit unclear.
What are you trying to achieve? Just build another backend for my antispam plugin?
In backend_handle_mail I put store the signature returned from signature_extract into my antispam_transaction_context. In backend_commit it appears that the signature is empty. (It wasn't in backend_handle_mail).
Somehow between backend_handle_mail en backend_commit it has been cleared... When I use i_strdup it appears to work. Anyone can tell me where this clearing happens? Is i_strdup the right way to do it then?
Well, how did you put it in there? It's well possible that the memory was allocated on a stack or in a pool that has been cleared/freed...
johannes
Johannes Berg wrote:
Hi,
I'm trying to build another antispam plugin, but some things are a bit unclear.
What are you trying to achieve? Just build another backend for my antispam plugin? Yes, just another backend. It would be logging the signatures to a mysql database, so that I can process the signatures with dspam at a convenient time.
I'll use the sql functions available in the sql-api.h from dovecot. I'll probably store a global sql_db, so I don't need to open/close connections for every message.
In backend_handle_mail I put store the signature returned from signature_extract into my antispam_transaction_context. In backend_commit it appears that the signature is empty. (It wasn't in backend_handle_mail).
Somehow between backend_handle_mail en backend_commit it has been cleared... When I use i_strdup it appears to work. Anyone can tell me where this clearing happens? Is i_strdup the right way to do it then?
Well, how did you put it in there? It's well possible that the memory was allocated on a stack or in a pool that has been cleared/freed...
My antispam_transaction_context contains a const char* signature.
in backend_handle_mail: ast->signature = signature_extract(t, mail);
Then in backend_commit: debug("backend_commit %p SIG: %s CLASS: %u", ast, ast->signature ? ast->signature : "/", ast->classification);
signature appears to be an empty string there. When using i_strdup in backend_handle_mail it seems to work.
Thanks,
Alexander
On Sat, 2008-04-19 at 15:12 +0200, Alexander Prinsier wrote:
Johannes Berg wrote:
Hi,
I'm trying to build another antispam plugin, but some things are a bit unclear.
What are you trying to achieve? Just build another backend for my antispam plugin? Yes, just another backend. It would be logging the signatures to a mysql database, so that I can process the signatures with dspam at a convenient time.
I'll use the sql functions available in the sql-api.h from dovecot. I'll probably store a global sql_db, so I don't need to open/close connections for every message.
In backend_handle_mail I put store the signature returned from signature_extract into my antispam_transaction_context. In backend_commit it appears that the signature is empty. (It wasn't in backend_handle_mail).
Somehow between backend_handle_mail en backend_commit it has been cleared... When I use i_strdup it appears to work. Anyone can tell me where this clearing happens? Is i_strdup the right way to do it then?
Well, how did you put it in there? It's well possible that the memory was allocated on a stack or in a pool that has been cleared/freed...
My antispam_transaction_context contains a const char* signature.
in backend_handle_mail: ast->signature = signature_extract(t, mail);
Then in backend_commit: debug("backend_commit %p SIG: %s CLASS: %u", ast, ast->signature ? ast->signature : "/", ast->classification);
signature appears to be an empty string there. When using i_strdup in backend_handle_mail it seems to work.
You have to i_strdup() it and also free it later, the signature code just gives you a pointer that is valid as long as the mail struct lives (IIRC)
johannes
Surely spam filtering/rejection should be done by the MTA, preferably during the SMTP protocol conversation so as to prevent the black-holing of legitimate e-mails (i.e. the sender doesn't know it's not been delivered) and the prevention of joe-job collateral spamming?
It should also be noted that, at least in the UK, the act of an MTA at the final delivery mail server accepting an e-mail means that it's legally been received. Hence, any legal document which the MTA accepts has been deemed to have been legally served even if no human ever reads it.
Please be careful, e-mail administration can be a legal minefield!
Steve
Computer Systems Administrator, E-Mail:-steve@earth.ox.ac.uk Department of Earth Sciences, Tel:- +44 (0)1865 282110 University of Oxford, Parks Road, Oxford, UK. Fax:- +44 (0)1865 272072
participants (3)
-
Alexander Prinsier
-
Johannes Berg
-
Stephen Usher