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