[Dovecot] building a simple antispam plugin
dovecot at aphexer.mailhaven.com
Sat Apr 19 16:12:07 EEST 2008
Johannes Berg wrote:
>> I'm trying to build another antispam plugin, but some things are a bit
> 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
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
>> 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.
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.
More information about the dovecot