[Dovecot] mailtrain with dovecot antispam plugin
Hugo Monteiro
hugo.monteiro at fct.unl.pt
Thu Apr 24 01:41:09 EEST 2008
Johannes Berg wrote:
> Please don't take mail private. I tend to not reply at all in that case.
>
> Can you try this patch?
>
> johannes
>
> diff --git a/mailtrain.c b/mailtrain.c
> index dbe770c..75c0fc8 100644
> --- a/mailtrain.c
> +++ b/mailtrain.c
> @@ -213,7 +213,9 @@ int backend_handle_mail(struct mailbox_transaction_context *t,
> struct istream *mailstream;
> struct ostream *outstream;
> int ret;
> - char *buf, *firstline;
> + char *buf;
> + const unsigned char *beginning;
> + size_t size;
> int fd;
>
> if (!ast->tmpdir) {
> @@ -266,15 +268,25 @@ int backend_handle_mail(struct mailbox_transaction_context *t,
> goto failed_to_copy;
> }
>
> - firstline = i_stream_read_next_line(mailstream);
> + if (i_stream_read_data(mailstream, &beginning, &size, 5) < 0 ||
> + size < 5) {
> + ret = -1;
> + mail_storage_set_error(t->box->storage,
> + "Failed to read mail beginning");
> + goto failed_to_copy;
> + }
>
> - if (strncmp(firstline, "From ", 5) != 0)
> - if (o_stream_send_str(outstream, firstline) < 0) {
> + /* "From "? skip line */
> + if (memcmp("From ", beginning, 5) == 0) {
> + i_stream_read_next_line(mailstream);
> + } else {
> + if (o_stream_send_str(outstream, "From ") < 0) {
> ret = -1;
> mail_storage_set_error(t->box->storage,
> "Failed to write line to temp");
> goto failed_to_copy;
> }
> + }
>
> if (o_stream_send_istream(outstream, mailstream) < 0) {
> ret = -1;
>
>
>
>
Hello Johannes,
sorry taking it off the list. Didn't want to bother the others with my
whining.. ;)
I've briefly tested the patch you sugested and it seems to work like a
charm.
Thank you for your interest.
Best regards,
Hugo Monteiro.
--
ci.fct.unl.pt:~# cat .signature
Hugo Monteiro
Email : hugo.monteiro at 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 at fct.unl.pt
ci.fct.unl.pt:~# _
More information about the dovecot
mailing list