Re: Python module for HTTP API

2021-06-08 Thread Alex Baule
Python Requests is easy to use.

https://docs.python-requests.org/en/master/

Em ter., 8 de jun. de 2021 às 14:30, Michael Ströder 
escreveu:

> HI!
>
> Can anybody recommend a high-level Python module for accessing doveadm's
> HTTP API? [1]
>
> Ciao, Michael.
>
> [1] https://doc.dovecot.org/admin_manual/doveadm_http_api/
>


Re: [Dovecot] INBOX cant be created

2012-03-19 Thread Alex Baule
doveadm(admin): Error: Can't create mailbox INBOX: Permission denied

The INBOX exists but has a wrong owner.


Em 19 de março de 2012 13:22, Radim Kolar  escreveu:

> doveadm does not works too:
>
> sudo doveadm mailbox create -u admin INBOX
> doveadm(admin): Error: Can't create mailbox INBOX: Permission denied
> sudo doveadm mailbox create -u admin INBOX.2
> (works)
>


Re: [Dovecot] Creating and interacting with array inside plugin

2012-02-23 Thread Alex Baule
Tks Timo...



Em 23 de fevereiro de 2012 21:34, Timo Sirainen  escreveu:
> On 23.2.2012, at 18.19, Alex Baule wrote:
>
>> ok, inside my expunged rewrite function i create the array like quota
>> does, and append it to my array.
>>
>> struct emexis_ids_x_uis append_uis;
>> append_uis.ids = _mail->uid;
>> append_uis.uis_file = bodyFile;
> ..
>> But when i do a foreach in this Array, my ids is OK, but my uis_file
>> has tha same value every time (the value is the lasted value
>> inserted).
>
> I guess the memory isn't permanently allocated for it, so you need to do:
>
> append_uis.uis_file = i_strdup(bodyFile);
>
> Note that you'll also need to later i_free() it to avoid leaking memory.
>


Re: [Dovecot] There is a way to know if a email has been expunged ?

2012-02-16 Thread Alex Baule
hi Timo, now its works.. i do in the old way, my dovecot is 2.0.15.

You say it "old way", when it's change ? in dovecot 2.0.18 is in the
old or new way ?

I asking because if i update dovecot, i need to update the plugin.

Tks !


Em 13 de fevereiro de 2012 18:18, Timo Sirainen  escreveu:
> On 13.2.2012, at 19.28, Alex Baule wrote:
>
>> static void emexis_mailbox_allocated(struct mailbox *box)
>> {
>>    union mailbox_module_context *zbox;
>>
>>    zbox = p_new(box->pool, union mailbox_module_context, 1);
>>    zbox->super = box->v;
>>    box->v.open = Mplugin_mailbox_open;
>>    box->v.sync_notify = Mplugin_mailbox_sync_notify;
>>
>>    MODULE_CONTEXT_SET_SELF(box, emexis_storage_module, zbox);
>> }
>
> The above is an "old way" to do it. It doesn't work well if you have any 
> other plugins loaded.
>
>> struct mailbox_vfuncs *v = box->vlast;
>> v->sync_notify = Mplugin_mailbox_sync_notify;
>>
>> But in this two cases, the Mplugin_mailbox_sync_notify is never
>> called... i missing something ??
>
> Never called at all? What storage backend are you using as the base? Maildir?
>
> Anyway, the way you should be calling it is the exact same way quota plugin 
> does:
>
> void Mplugin_mailbox_allocated(struct mailbox *box)
> {
>        struct mailbox_vfuncs *v = box->vlast;
>        union mailbox_module_context *zbox;
>
>        zbox = p_new(box->pool, union mailbox_module_context, 1);
>        zbox->super = *v;
>        box->vlast = &zbox->super;
>
>        v->open = Mplugin_mailbox_open;
>        v->sync_notify = Mplugin_mailbox_sync_notify;
>        MODULE_CONTEXT_SET_SELF(box, Mplugin_storage_module, zbox);
> }
>


Re: [Dovecot] There is a way to know if a email has been expunged ?

2012-02-13 Thread Alex Baule
Hi Again Timo !

I Trying to port quota plugin notify_sync to my plugin, but i found some issues.

I have the hooks already, to replace the mailbx_allocated, like quota
plugin does.

static struct mail_storage_hooks emexis_mail_storage_hooks = {
.mail_user_created = Mplugin_mail_user_created,
.mailbox_allocated = Mplugin_mailbox_allocated,
.mail_allocated = Mplugin_mail_allocated,
.mailbox_list_created = Mplugin_mailbox_list_created,
.mail_namespaces_created = Mplugin_antispam_mail_namespaces_created
};

inside the Mplugin_mailbox_allocated, i have:

static void emexis_mailbox_allocated(struct mailbox *box)
{
union mailbox_module_context *zbox;

zbox = p_new(box->pool, union mailbox_module_context, 1);
zbox->super = box->v;
box->v.open = Mplugin_mailbox_open;
box->v.sync_notify = Mplugin_mailbox_sync_notify;

MODULE_CONTEXT_SET_SELF(box, emexis_storage_module, zbox);
}

The v.open i rewrite because my plugin needs.

I try to call the sync_notify like this:

box->v.sync_notify = Mplugin_mailbox_sync_notify;

and follow quota plugin, i try to to this too:

struct mailbox_vfuncs *v = box->vlast;
v->sync_notify = Mplugin_mailbox_sync_notify;

But in this two cases, the Mplugin_mailbox_sync_notify is never
called... i missing something ??

Tks !


Em 12 de fevereiro de 2012 14:48, Alex Baule  escreveu:
> Tks timo !
>
> I will see the plugin to do like it!
>
> Em 12/02/2012 13:46, "Timo Sirainen"  escreveu:
>
>> Hi,
>>
>> Yeah, you shouldn't do the erasing directly in expunge(), because it may
>> still be aborted. Do it in sync_notify() like quota plugin does.
>>
>> On 12.2.2012, at 16.52, Alex Baule wrote:
>>
>> > I want to know because i have header and body splited. To erase the
>> > body, i must have shure, that header was expunged. Some tests that i
>> > made, the client call expunge, but i don't  know why (there is notting
>> > in mail log) the header was not expunged, nut my body was, because i
>> > call it before expunge the header. something like this.
>> >
>> > if (found_body){
>> >    erase_body();
>> >    super.expunge(_mail);
>> > }
>> >
>> > Because that expunge that no happen, (the client call, but the email
>> > was not expunged) i think to do like this way:
>> >
>> > if (found_body){
>> >   super.expunge(_mail);
>> >   if(_mail was expunged){
>> >      erase_body();
>> >  }
>> > }
>> >
>> > TKs Timo !
>> >
>> > Em 12 de fevereiro de 2012 02:19, Timo Sirainen  escreveu:
>> >> On 10.2.2012, at 19.39, Alex Baule wrote:
>> >>
>> >>> Hy Everyone...and Timo !
>> >>>
>> >>> There is a way to know if a email was expunged (deleted from hard
>> >>> disk)  inside a plugin ? I rewrite the expunge function, but the real
>> >>> expunge function is void, i can't know if was really expunged.
>> >>>
>> >>> There is a way to know this ?
>> >>
>> >> It's not known until transaction_commit() what messages are expunged.
>> >> What do you need to know this for? There are a few different ways.
>> >>
>> >> If you simply need one of the sessions to definitely know that it
>> >> expunged a message, you can do it like quota plugin does. (So even if 
>> >> there
>> >> are multiple clients doing EXPUNGE at the same time, quota is never
>> >> decreased more than once per mail.) See quota-storage.c and most 
>> >> importantly
>> >> quota_mailbox_sync_notify().
>> >>
>> >> Quota code also shows the other method of doing it: keep track of what
>> >> mail_expunge()s have been called, and then in transaction commit check if 
>> >> it
>> >> succeeds and if it does do what you want to do.
>> >>
>> >
>>
>


Re: [Dovecot] There is a way to know if a email has been expunged ?

2012-02-12 Thread Alex Baule
Tks timo !

I will see the plugin to do like it!
Em 12/02/2012 13:46, "Timo Sirainen"  escreveu:

> Hi,
>
> Yeah, you shouldn't do the erasing directly in expunge(), because it may
> still be aborted. Do it in sync_notify() like quota plugin does.
>
> On 12.2.2012, at 16.52, Alex Baule wrote:
>
> > I want to know because i have header and body splited. To erase the
> > body, i must have shure, that header was expunged. Some tests that i
> > made, the client call expunge, but i don't  know why (there is notting
> > in mail log) the header was not expunged, nut my body was, because i
> > call it before expunge the header. something like this.
> >
> > if (found_body){
> >erase_body();
> >super.expunge(_mail);
> > }
> >
> > Because that expunge that no happen, (the client call, but the email
> > was not expunged) i think to do like this way:
> >
> > if (found_body){
> >   super.expunge(_mail);
> >   if(_mail was expunged){
> >      erase_body();
> >  }
> > }
> >
> > TKs Timo !
> >
> > Em 12 de fevereiro de 2012 02:19, Timo Sirainen  escreveu:
> >> On 10.2.2012, at 19.39, Alex Baule wrote:
> >>
> >>> Hy Everyone...and Timo !
> >>>
> >>> There is a way to know if a email was expunged (deleted from hard
> >>> disk)  inside a plugin ? I rewrite the expunge function, but the real
> >>> expunge function is void, i can't know if was really expunged.
> >>>
> >>> There is a way to know this ?
> >>
> >> It's not known until transaction_commit() what messages are expunged.
> What do you need to know this for? There are a few different ways.
> >>
> >> If you simply need one of the sessions to definitely know that it
> expunged a message, you can do it like quota plugin does. (So even if there
> are multiple clients doing EXPUNGE at the same time, quota is never
> decreased more than once per mail.) See quota-storage.c and most
> importantly quota_mailbox_sync_notify().
> >>
> >> Quota code also shows the other method of doing it: keep track of what
> mail_expunge()s have been called, and then in transaction commit check if
> it succeeds and if it does do what you want to do.
> >>
> >
>
>


Re: [Dovecot] There is a way to know if a email has been expunged ?

2012-02-12 Thread Alex Baule
I want to know because i have header and body splited. To erase the
body, i must have shure, that header was expunged. Some tests that i
made, the client call expunge, but i don't  know why (there is notting
in mail log) the header was not expunged, nut my body was, because i
call it before expunge the header. something like this.

if (found_body){
erase_body();
super.expunge(_mail);
}

Because that expunge that no happen, (the client call, but the email
was not expunged) i think to do like this way:

if (found_body){
   super.expunge(_mail);
   if(_mail was expunged){
  erase_body();
  }
}

TKs Timo !

Em 12 de fevereiro de 2012 02:19, Timo Sirainen  escreveu:
> On 10.2.2012, at 19.39, Alex Baule wrote:
>
>> Hy Everyone...and Timo !
>>
>> There is a way to know if a email was expunged (deleted from hard
>> disk)  inside a plugin ? I rewrite the expunge function, but the real
>> expunge function is void, i can't know if was really expunged.
>>
>> There is a way to know this ?
>
> It's not known until transaction_commit() what messages are expunged. What do 
> you need to know this for? There are a few different ways.
>
> If you simply need one of the sessions to definitely know that it expunged a 
> message, you can do it like quota plugin does. (So even if there are multiple 
> clients doing EXPUNGE at the same time, quota is never decreased more than 
> once per mail.) See quota-storage.c and most importantly 
> quota_mailbox_sync_notify().
>
> Quota code also shows the other method of doing it: keep track of what 
> mail_expunge()s have been called, and then in transaction commit check if it 
> succeeds and if it does do what you want to do.
>


[Dovecot] There is a way to know if a email has been expunged ?

2012-02-10 Thread Alex Baule
Hy Everyone...and Timo !

There is a way to know if a email was expunged (deleted from hard
disk)  inside a plugin ? I rewrite the expunge function, but the real
expunge function is void, i can't know if was really expunged.

There is a way to know this ?


[Dovecot] Rewrite the ostream output method, to save messages in another directory.

2011-10-31 Thread Alex Baule
Hi Timo,

I Trying to integrate my antispam with dovecot, using the imap folder to do
certain actions. I Do almost every thing, but i have some problems saving
the message.

Explaining this function, i try to use a imap folder like a "collector
folder", the user append a message from outside (ie another imap or pop
message) to this folder, and i don't want to copy this message, i need to
redirect it to another folder outside from user's maildir.

Well, i try to base it in zlib plugin, with  was the o_stream_create_gz().

Inside the o_stream_create_gz has the Output, it's a copy from the original
output.

I Try to replace this output, with another one, that i try to create to
another location, without sucessfull.

struct ostream *
o_stream_create_X_list(struct ostream *output, struct istream *input, const
char *type)
{
struct emexis_ostream *X_stream;
struct ostream *new_output;
int fd;

fd = open("/tmp/email",O_WRONLY);

new_output = o_stream_create_fd_file(fd, 0, TRUE);
o_stream_cork(new_output);

emexis_stream = i_new(struct emexis_ostream, 1);
emexis_stream->ostream.sendv = o_stream_X_sendv;
emexis_stream->ostream.flush = o_stream_X_flush;
emexis_stream->ostream.iostream.close = o_stream_X_close;
emexis_stream->output = new_output;
emexis_stream->input = input;

o_stream_ref(new_output);

return o_stream_create(&X_stream->ostream);
}


With this new o_stream, i got this error.

Oct 27 15:14:24 brc dovecot: imap(a...@exemplo.com.br): Error:
o_stream_send_istream(/storage/gss/emexis/messages/
exemplo.com.br/alex/Maildir/.Emexis.Ext-Blacklist/tmp/1319735664.M568409P30815.brc)
failed: Bad file descriptor
Oct 27 15:14:24 brc dovecot: imap(a...@exemplo.com.br): Error:
o_stream_flush(/storage/gss/emexis/messages/
exemplo.com.br/alex/Maildir/.Emexis.Ext-Blacklist/tmp/1319735664.M568409P30815.brc)
failed: Bad file descriptor
Oct 27 15:14:24 brc dovecot: imap(a...@exemplo.com.br): Error:
write(/storage/gss/emexis/messages/
exemplo.com.br/alex/Maildir/.Emexis.Ext-Blacklist/tmp/1319735664.M568409P30815.brc)
failed: Bad file descriptor

There is something wrong Timo ? Like missing something or i need to rewrite
another funcion ?

Tks  !!!


dovecot@dovecot.org

2011-06-13 Thread Alex Baule
my delivery is done by the exim, and i use maildir.
Well, i will use the mail_get_first_header with the Return-Path.

Tks.
 Em 13/06/2011 10:09, "Timo Sirainen"  escreveu:
> On Fri, 2011-06-10 at 09:19 -0300, Alex Baule wrote:
>> Hi Timo...
>>
>> Inside my plugin, i use the (mail_get_first_header(mail, "From",
>> &header) function, to get the email From to put in some Blacklist.
>>
>> Looking in the header under this mail, we have 2 "From" fields.
>
> Do you mean these?
>
> From dma_3...@envios.socomdescontos.com.br Tue Jun 07 15:43:04 2011
> From: "CompraFacil.com.br" 
>
>> Using the function above, i get the Second "From", but my MTA (exim)
>> look in to The First From, in the First Line, in that way, my
>> blacklist don't work, because the sender to be blocked is different
>> from
>>
>> the From looked by dovecot.
>>
>> There is a way to get the "From" from First line ?
>
> The first line isn't a From: header. It's the "envelope sender". That
> line typically exists only with mbox format, not with other mailbox
> formats.. If you deliver a mail via dovecot-lda it removes this From
> line if it sees it.
>
> Typically you'd get this info from Return-Path: header.
>


dovecot@dovecot.org

2011-06-10 Thread Alex Baule
Hi Timo...

Inside my plugin, i use the (mail_get_first_header(mail, "From",
&header) function, to get the email From to put in some Blacklist.

Looking in the header under this mail, we have 2 "From" fields.

Using the function above, i get the Second "From", but my MTA (exim)
look in to The First From, in the First Line, in that way, my
blacklist don't work, because the sender to be blocked is different
from

the From looked by dovecot.

There is a way to get the "From" from First line ?



## HEADER

>From dma_3...@envios.socomdescontos.com.br Tue Jun 07 15:43:04 2011
Return-path: 
Envelope-to: suges...@brc.com.br
Delivery-date: Tue, 07 Jun 2011 15:43:04 -0300
Received: from [187.61.43.119] (helo=vt-0007-119.virtualtarget.com.br)
by mail.brc.com.br with esmtp (Exim 4.76)
(envelope-from )
id 1QU1Ex-0006II-5o
for suges...@brc.com.br; Tue, 07 Jun 2011 15:43:01 -0300
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; s=k1; d=dkim.vttrack.com.br;
 
h=From:To:Subject:MIME-Version:Content-Type:Reply-To:List-Unsubscribe:Message-ID:Date;
 bh=Q5G3TQPrYgogLS7aDg1DLYJpLKI=;
 b=XC+MHH79L6VHTI2OayuFHZGeSRAvNstNz8sHEp+xE5i71GznnYfCVsw7fuq2dIST6bTYY7tto/Rd
   aIZjc2YfEyqgUi0KKKesnMLSI61Ij/FlmE5ftRgIy9Ra59O9R03S62wAt6WPjkx1f4xCZ9ZAIaox
   GU957biBsg3B6ryU5Ks=
Received: by vt-0007-119.virtualtarget.com.br id htpoj60sh70i for
; Tue, 7 Jun 2011 15:42:59 -0300 (envelope-from
)
From: "CompraFacil.com.br" 
To: "sugestao" 
Subject: SUPER OFERTA: TV LCD 32” Full HD apenas 10x 129,99 reais com
FRETE ZERO. Aproveite.
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="b928815d46126f887c344b7d725aceb1"
Reply-To: "CompraFacil.com.br" 
List-Unsubscribe:

X-DMA: 8448122
X-UID: 8448122-74473
X-CID: 3783
X-TYP: MAIL
Message-ID: <0.0.1e.8df.1cc2542b91e3284.8...@vt-0007-119.virtualtarget.com.br>
Date: Tue, 7 Jun 2011 15:42:59 -0300


## HEADER



[Dovecot] Importing emails from mounted NFS to dovecot using doveadm

2011-05-04 Thread Alex Baule
Hello Timo

I try to import emails using doveadm, but i found one little issue to me,

my driver in auth is

auth_default_realm = exemplo.com.br
auth_mechanisms = LOGIN PLAIN
passdb {
driver  = pam
}
userdb {
driver = static
args = uid=mail gid=mail home=/storage/gss/emexis/messages/%d/%n
allow_all_users=yes
}


but my emails to import in NFS i cant change the UID-GID to mail:mail,
because is in use by another IMAP  (in one machine uid X is different from
another machine)

There is a way to import emails with doveadm without change the owner from
my emails to import ?


[Dovecot] Rewrite the mailbox copy functions works in imap but don't work in doveadm import command

2011-01-19 Thread Alex Baule
Hi Timo !!

I rewrite the copy function from mailbox (using a plugin)

My rewrite is like this:

static int emexis_antispam_copy(struct mail_save_context *ctx, struct mail
*mail){
struct mailbox *box = ctx->transaction->box;
union mailbox_module_context *zbox = EMEXIS_CONTEXT(box);
struct mail_private *_mail = (struct mail_private *)mail;
union mail_module_context *zmail = EMEXIS_MAIL_CONTEXT(_mail);
struct istream *input;
const char *headerFile;
char *bodyFile;
int fd;
int increment;

..Do some stuffs and verifications OK

// GETTING THE FILE TO READ SOME STUFF FROM HEADER.
if (zmail->super.get_stream(mail, NULL, NULL, &input) >= 0){
i_warning("GET STREAM COPY OK...");
}else{
i_warning("GET STREAM COPY NOT OK...");
}
// REALLY COPY EMAIL
copyret = zbox->super.copy(ctx, mail);
}


OK, when i use the IMAP , using a client and copy a email, it's  works fine.

But, when i use a doveadm import command, the part
"(zmail->super.get_stream(mail, NULL, NULL, &input) >= 0)" fails, with no
error message, only a segfault

doveadm[14980]: segfault at 9c ip b7698000 sp bf83d7d0 error 4 in
libdovecot.so.0.0.0[b7663000+6d000]
doveadm[14983]: segfault at 9c ip b7661000 sp bf9c9ee0 error 4 in
libdovecot.so.0.0.0[b762c000+6d000]
doveadm[14986]: segfault at 9c ip b75b3000 sp bfcd82e0 error 4 in
libdovecot.so.0.0.0[b757e000+6d000]
doveadm[14989]: segfault at 9c ip b7684000 sp bfa5d3c0 error 4 in
libdovecot.so.0.0.0[b764f000+6d000]


There is difference between imap using a client , and doveadm import command
? If have some difference, can i identify and do some workarround ?

Tks Timo !!


Re: [Dovecot] Strange issue in NFS

2011-01-19 Thread Alex Baule
There is Strange

Jan 19 13:15:54 brc dovecot: imap(a...@exemplo.com.br): Error:
mremap_anon(3166208) failed: Cannot allocate memory
Jan 19 13:15:54 brc dovecot: imap(a...@exemplo.com.br): Error:
mremap_anon(3231744) failed: Cannot allocate memory
Jan 19 13:15:54 brc dovecot: imap(a...@exemplo.com.br): Error:
mremap_anon(3293184) failed: Cannot allocate memory
Jan 19 13:15:55 brc dovecot: imap(a...@exemplo.com.br): Error:
mremap_anon(3424256) failed: Cannot allocate memory
Jan 19 13:15:55 brc dovecot: imap(a...@exemplo.com.br): Error:
mremap_anon(3555328) failed: Cannot allocate memory
Jan 19 13:15:55 brc dovecot: imap(a...@exemplo.com.br): Error:
mremap_anon(3633152) failed: Cannot allocate memory
Jan 19 13:15:55 brc dovecot: imap(a...@exemplo.com.br): Error:
mremap_anon(3686400) failed: Cannot allocate memory
Jan 19 13:15:56 brc dovecot: imap(a...@exemplo.com.br): Error:
mremap_anon(3948544) failed: Cannot allocate memory
Jan 19 13:15:56 brc dovecot: imap(a...@exemplo.com.br): Error:
mremap_anon(4005888) failed: Cannot allocate memory
Jan 19 13:15:57 brc dovecot: imap(a...@exemplo.com.br): Error:
mremap_anon(3141632) failed: Cannot allocate memory
Jan 19 13:15:57 brc dovecot: imap(a...@exemplo.com.br): Error: read() failed
with file /storage/nfs/3/emexis/messages/
exemplo.com.br/alex/Maildir/dovecot.index.cache: Cannot allocate memory
Jan 19 13:15:57 brc dovecot: imap(a...@exemplo.com.br): Error:
opendir(/storage/nfs/3/emexis/messages/exemplo.com.br/alex/Maildir/new)
failed: Cannot allocate memory



That can be a nfs client error ? Something like error in nfs client with
memory allocation ?


2011/1/16 Timo Sirainen 

> On Wed, 2011-01-12 at 11:08 -0200, Alex Baule wrote:
> > Jan 12 10:57:50 brc dovecot: imap(a...@exemplo.com.br): Error:
> > opendir(/storage/nfs/3/emexis/messages/
> > exemplo.com.br/alex/Maildir/.Drafts/new) failed: Cannot allocate memory
>
> I've never seen opendir() fail with ENOMEM before.
>
> > Jan 12 10:57:51 brc last message repeated 4 times
> > Jan 12 10:57:59 brc dovecot: imap(a...@exemplo.com.br): Fatal:
> > block_alloc(262144): Out of memory
>
> My guess: You're going into infinite loop somewhere that keeps
> allocating memory.
>
> > What is most used "Shared Disk" in Dovecot ?
>
> People use NFS, GFS2, OCFS2, etc.
>
>


[Dovecot] Strange issue in NFS

2011-01-12 Thread Alex Baule
Hi Timo...

It's happens some strange issue with my maildir using NFS.

If i use a Local Hard disk, i don't get any of this messages about memory
error.

Jan 12 10:57:50 brc dovecot: imap(a...@exemplo.com.br): Error:
opendir(/storage/nfs/3/emexis/messages/
exemplo.com.br/alex/Maildir/.Drafts/new) failed: Cannot allocate memory
Jan 12 10:57:51 brc last message repeated 4 times
Jan 12 10:57:59 brc dovecot: imap(a...@exemplo.com.br): Fatal:
block_alloc(262144): Out of memory
Jan 12 10:57:59 brc dovecot: imap(a...@exemplo.com.br): Error: Raw
backtrace: /opt/addons/lib/dovecot/libdovecot.so.0 [0xb768fcbe] ->
/opt/addons/lib/dovecot/libdovecot.so.0 [0xb768fd1d] ->
/opt/addons/lib/dovecot/libdovecot.so.0 [0xb768f273] ->
/opt/addons/lib/dovecot/libdovecot.so.0 [0xb76a0183] ->
/opt/addons/lib/dovecot/libdovecot.so.0 [0xb76a01cc] ->
/opt/addons/lib/dovecot/libdovecot.so.0(p_strdup+0x40) [0xb76ad980] ->
/opt/addons/lib/dovecot/libdovecot-storage.so.0(maildir_save_add+0x7c)
[0xb7717f0c] ->
/opt/addons/lib/dovecot/libdovecot-storage.so.0(maildir_copy+0x18d)
[0xb7719bbd] -> /opt/addons/lib/dovecot/lib20_emexis_uis_plugin.so
[0xb74fda6a] ->
/opt/addons/lib/dovecot/libdovecot-storage.so.0(mailbox_copy+0x58)
[0xb76ea258] -> dovecot/imap(cmd_copy+0x1cf) [0x804f87f] ->
dovecot/imap(cmd_uid+0x7f) [0x80551bf] -> dovecot/imap [0x8055f0c] ->
dovecot/imap [0x8055fbb] -> dovecot/imap(client_handle_input+0x3f)
[0x805610f] -> dovecot/imap(client_input+0x5f) [0x8056acf] ->
/opt/addons/lib/dovecot/libdo
Jan 12 10:57:59 brc dovecot: master: Error: service(imap): child 28315
returned error 83 (Out of memory (vsz_limit=256 MB, you may need to increase
it))


I Try to increase the vsz_limit in imap to 2048 MB, and i try too , put 0 MB
(like no limit) and i still get this same error (only change the vsz_limit
to my write limit).

What is most used "Shared Disk" in Dovecot ?

Tks Timo !!


Re: [Dovecot] Plugins on a NFS

2010-12-16 Thread Alex Baule
Hi timo...

I Search in lib to see how the nfs_flush* works , and i see this too.

int nfs_safe_stat(const char *path, struct stat *buf);

can i use this too ? it's get a better handle with this + nfs_flush* before
?!

Tks !


2010/12/16 Timo Sirainen 

> On Thu, 2010-12-16 at 09:30 -0200, Alex Baule wrote:
>
> > I Made a plugin that's works fine in a Normal Partition and a GlusterFS
> > enviroment too.
> > in NFS it's intermitent, some times works, some times don't.
> > Only the expunge part have this issue, i use stat to get the amont of
> hard
> > link in a file.
> > There is because of that (stat, hard link count) ?
>
> No, hard links work fine with NFS. If you have multiple servers
> accessing the same storage via NFS, then it's possible that stat()
> result is cached and the hard link count may be out of date. You could
> try running nfs_flush_attr_cache_unlocked() before the stat(), but that
> doesn't work perfectly.
>
>
>


[Dovecot] Plugins on a NFS

2010-12-16 Thread Alex Baule
Hi timo.

I Made a plugin that's works fine in a Normal Partition and a GlusterFS
enviroment too.
in NFS it's intermitent, some times works, some times don't.
Only the expunge part have this issue, i use stat to get the amont of hard
link in a file.
There is because of that (stat, hard link count) ?

If is, there is some workarround to do !?

Tks Timo !!!


Re: [Dovecot] Mailbox Delete

2010-11-26 Thread Alex Baule
It's  strange, because if i comment the call for my function mailbox_delete,
i don't get the error.

Only if i delete it.

i will check the rest of code...

Tks Timo !



2010/11/26 Timo Sirainen 

> On 26.11.2010, at 19.47, Alex Baule wrote:
>
> >box = mailbox_alloc(ns->list, name, 0);
> >if (mailbox_delete(box) < 0) {
> >struct mail_storage *storage = mailbox_get_storage(box);
> >i_error("Can't delete mailbox %s: %s",
> > name,mail_storage_get_last_error(storage, NULL));
> >}
>
> This should be enough.
>
> >if (mailbox_mark_index_deleted(box, TRUE) < 0){
> >struct mail_storage *storage = mailbox_get_storage(box);
> >i_error("Can't delete INDEX %s: %s",
> > name,mail_storage_get_last_error(storage, NULL));
> >}
>
> The mailbox_delete() calls this internally, you shouldn't do it.
>
> >
> /opt/addons/lib/dovecot/libdovecot-storage.so.0(index_storage_get_status+0x38d)
> > [0xb770aced] -> /opt/addons/lib/dovecot/lib20_emexis_uis_plugin.so
> > [0xb75009a1] ->
> > /opt/addons/lib/dovecot/libdovecot-storage.so.0(mailbox_delete+0x4e)
>
> Anyway, this points to the problem being in emexis_uis plugin. It's calling
> mailbox_get_status() in a delete hook without having the mailbox opened yet.
> It should probably be calling mailbox_open() first.


[Dovecot] Mailbox Delete

2010-11-26 Thread Alex Baule
Hi Timo

I Modify the plugin autocreate, that create and subscribe a mailbox to user.

My modification consist in do the inverse, if my user don't have permission
to create and subscribe a folder, the plugin remove and unsubscribe.

My function is called in the same place that create and subscribe is called,
just seeing if my flag is "create or delete".

My function i copy from doveadm + autocreate create mailbox.

The delete is made, and works, but i got some errors before the delete.

I thing that is missing something in this function, like delete something
else

static void
emexis_antispam_mailbox_delete(struct mail_namespace *namespaces, const char
*name)
{

struct mail_namespace *ns;
struct mailbox *box;
ns = mail_namespace_find(namespaces, &name);
if (ns != NULL){
box = mailbox_alloc(ns->list, name, 0);
if (mailbox_delete(box) < 0) {
struct mail_storage *storage = mailbox_get_storage(box);
i_error("Can't delete mailbox %s: %s",
name,mail_storage_get_last_error(storage, NULL));
}
if (mailbox_mark_index_deleted(box, TRUE) < 0){
struct mail_storage *storage = mailbox_get_storage(box);
i_error("Can't delete INDEX %s: %s",
name,mail_storage_get_last_error(storage, NULL));
}
mailbox_free(&box);
}
}

I got this errors.

Nov 26 17:39:29 brc dovecot: imap(a...@exemplo.com.br): Panic: file
index-status.c: line 144 (index_storage_get_status): assertion failed:
(box->opened)
Nov 26 17:39:29 brc dovecot: imap(a...@exemplo.com.br): Error: Raw
backtrace: /opt/addons/lib/dovecot/libdovecot.so.0 [0xb769275e] ->
/opt/addons/lib/dovecot/libdovecot.so.0 [0xb76927bd] ->
/opt/addons/lib/dovecot/libdovecot.so.0 [0xb7691db4] ->
/opt/addons/lib/dovecot/libdovecot-storage.so.0(index_storage_get_status+0x38d)
[0xb770aced] -> /opt/addons/lib/dovecot/lib20_emexis_uis_plugin.so
[0xb75009a1] ->
/opt/addons/lib/dovecot/libdovecot-storage.so.0(mailbox_delete+0x4e)
[0xb76ed36e] -> /opt/addons/lib/dovecot/lib20_emexis_uis_plugin.so
[0xb74fff10] -> /opt/addons/lib/dovecot/lib20_emexis_uis_plugin.so
[0xb7500280] -> /opt/addons/lib/dovecot/lib20_emexis_uis_plugin.so
[0xb7500fa9] ->
/opt/addons/lib/dovecot/libdovecot-storage.so.0(hook_mail_namespaces_created+0x31)
[0xb76ee011] ->
/opt/addons/lib/dovecot/libdovecot-storage.so.0(mail_namespaces_init+0x7c4)
[0xb76e71d4] ->
/opt/addons/lib/dovecot/libdovecot-storage.so.0(mail_storage_service_next+0x21c)
[0xb76f4b9c] -> /opt/addons/lib/dovecot/libdovecot-stor
Nov 26 17:39:29 brc dovecot: master: Error: service(imap): child 2830 killed
with signal 6 (core dumps disabled)


TKS Timo !!!


Re: [Dovecot] Doveadm

2010-11-23 Thread Alex Baule
Thats Right !! some times i'm so stupid !! lol

i see in source code the

if (*ctx->dest_parent != '\0') {

But i forgot how to pass a NULL value, it´s with ""

Tks again !

PS.
This last fixes that you made in doveadm, will be avaliable at next release
? you think in some date ?




2010/11/23 Timo Sirainen 

> On Tue, 2010-11-23 at 13:54 -0200, Alex Baule wrote:
> > I'm Folling the Wiki, with say if put -8 , give the name in UTF-8, so i
> put
> > it here too.
> >
> > if was doing with doveadm it' be something like that:
> >
> > r...@brc:~ # doveadm mailbox list -8 -u a...@exemplo.com.br
>
> You still need to give the "-" character for doveadm-server too. Giving
> "8" without the "-" works the same in doveadm command line: it'll list
> mailboxes matching pattern "8". It makes more sense if you give e.g.
> "mailbox list foo*" which lists all mailboxes beginning with "foo".
>
> And anyway, -8 is the default, so it's not necessary to give it.
>
> > I was trying to import too , using the doveadm command line, but i can
> > import exactly the same struct to my maildir in dovecot.
> >
> > something like this:
> >
> > doveadm -Dv import -u a...@exemplo.com.br maildir:/root/Maildir  > DEST> all
> >
> > The  can't be the Maildir root dir, to be the exactly copy
> from
> > source Maildir.
>
> I think you can give "" as the ?
>
>


Re: [Dovecot] Doveadm

2010-11-23 Thread Alex Baule
I'm Folling the Wiki, with say if put -8 , give the name in UTF-8, so i put
it here too.

if was doing with doveadm it' be something like that:

r...@brc:~ # doveadm mailbox list -8 -u a...@exemplo.com.br
Emexis
Emexis.Whitelist
Emexis.Quarantine
Emexis.Blacklist
Trash
Sent
Archives
Drafts
r...@brc:~ #

I was trying to import too , using the doveadm command line, but i can
import exactly the same struct to my maildir in dovecot.

something like this:

doveadm -Dv import -u a...@exemplo.com.br maildir:/root/Maildir  all

The  can't be the Maildir root dir, to be the exactly copy from
source Maildir.

This can be useful, when you want to pass every messages in a
plugin(like my case, to split header and body)

There is possible ?

Tks again !



2010/11/23 Timo Sirainen 

> On Tue, 2010-11-23 at 09:07 -0200, Alex Baule wrote:
> > the command that i use now is:
> >
> > "version\tdoveadm-server\t1\t0\nd\ta...@exemplo.com.br\tmailbox
> list\t8\n"
> >
> > the command is OK, and i think the parameters too, but this not return
> the
> > mailbox list in unix socket.
>
> What's the "8" parameter doing there? You're now asking a mailbox list
> of a mailbox named "8", and if there is none you won't get any matches.
>
> > how is the protocol flow to doveadm unix socket ?
> >
> > something like.
> >
> > write X
> > Read Y
> > shutdown socket
> >
> > or have another order todo this ?
>
> Looks like there were several bugs. I fixed them now in hg. Anyway, you
> can now do:
>
> 1. Send VERSION
> 2. Send command
> 3. Read reply line (one for prints, one containing "+" or "-" =
> success/failure)
> 4. Disconnect or goto 2.
>
>


Re: [Dovecot] Doveadm

2010-11-23 Thread Alex Baule
Hi Timo

It's me again ! lol

the expunge command works fine in unix socket.

Now, i try to do others commands, like someone that return itens..

the command that i use now is:

"version\tdoveadm-server\t1\t0\nd\ta...@exemplo.com.br\tmailbox list\t8\n"

the command is OK, and i think the parameters too, but this not return the
mailbox list in unix socket.

how is the protocol flow to doveadm unix socket ?

something like.

write X
Read Y
shutdown socket

or have another order todo this ?

Tks !


2010/11/22 Alex Baule 

> Tks, now it's working, i need to send every in one "write",
> (header+command)
>
> 2010/11/22 Timo Sirainen 
>
> On Mon, 2010-11-22 at 13:38 -0200, Alex Baule wrote:
>>
>> > Im have a situation here with the syntax for doveadm in a unix socket.
>> >
>> > My string have it:
>> >
>> >  std::string ask = "d\texpunge\tu\ta...@exemplo.com.br
>> > \tmailbox\t\\*\tsavedbefore\t1s\n";
>>
>> Looks like there was also a bug, fixed:
>> http://hg.dovecot.org/dovecot-2.0/rev/b724ef3bdc0a
>>
>> So what you need to send is:
>>
>> VERSION\tdoveadm-server\t1\t0
>> d\tu...@domain\texpunge\tmailbox\t*\tsavedbefore\t1s
>>
>> There is no escaping for '*', in command line you need to do that only
>> because shell otherwise expands it.
>>
>>
>


Re: [Dovecot] Doveadm

2010-11-22 Thread Alex Baule
Tks, now it's working, i need to send every in one "write", (header+command)

2010/11/22 Timo Sirainen 

> On Mon, 2010-11-22 at 13:38 -0200, Alex Baule wrote:
>
> > Im have a situation here with the syntax for doveadm in a unix socket.
> >
> > My string have it:
> >
> >  std::string ask = "d\texpunge\tu\ta...@exemplo.com.br
> > \tmailbox\t\\*\tsavedbefore\t1s\n";
>
> Looks like there was also a bug, fixed:
> http://hg.dovecot.org/dovecot-2.0/rev/b724ef3bdc0a
>
> So what you need to send is:
>
> VERSION\tdoveadm-server\t1\t0
> d\tu...@domain\texpunge\tmailbox\t*\tsavedbefore\t1s
>
> There is no escaping for '*', in command line you need to do that only
> because shell otherwise expands it.
>
>


Re: [Dovecot] Doveadm

2010-11-22 Thread Alex Baule
Hi Timo

Im have a situation here with the syntax for doveadm in a unix socket.

My string have it:

 std::string ask = "d\texpunge\tu\ta...@exemplo.com.br
\tmailbox\t\\*\tsavedbefore\t1s\n";

My Order todo is.

Create socket
Connect
Write this strinng
Read the return
Close socket.
finish my program.

But Still i dont get messages to be expunged, if i call bu doveadm command
line, works...

There is some header to send before the command ?

Tks


2010/11/19 Alex Baule 

> Tks timo! Monday i will do all corrections!
>
> Em 19/11/2010 22:26, "Timo Sirainen" escreveu:
>
> On 19.11.2010, at 22.18, Alex Baule wrote:
>
> > The syntax for doveadm in socket, is the same as the d...
> Yes, but use tabs instead of spaces for separating parameters.
>
>


Re: [Dovecot] Doveadm

2010-11-19 Thread Alex Baule
Tks timo! Monday i will do all corrections!

Em 19/11/2010 22:26, "Timo Sirainen" escreveu:

On 19.11.2010, at 22.18, Alex Baule wrote:

> The syntax for doveadm in socket, is the same as the d...
Yes, but use tabs instead of spaces for separating parameters.


Re: [Dovecot] Doveadm

2010-11-19 Thread Alex Baule
Tks timo, my plugin is under imap and pop protocol, i will put it in global
conf.

The syntax for doveadm in socket, is the same as the doveadm app?

Ex. Doveadm expurge -u user mailbox inbox savedbefore 3w

Than i create a connection to unix socket and write in socket the "expunge
-u user mailbox inbox savedbefore 3w"

I made a small socket program, doing this but it doesnt work...

Tks Timo

Em 19/11/2010 18:16, "Timo Sirainen" escreveu:

On Fri, 2010-11-19 at 15:15 -0200, Alex Baule wrote:
> Hi Timo
>
> I have a doubt about the dov...
Yes, just like all other Dovecot processes, as long as you keep the
mail_plugins setting global (instead of e.g. inside protocol imap {}).


> if have a plugin using in IMAP, it's use this
> same plugin to do the work (ex> expurge, copy,etc...
As long as "doveconf mail_plugins" shows your plugin there, it's used.


Re: [Dovecot] Doveadm

2010-11-19 Thread Alex Baule
Hi Timo

I have a doubt about the doveadm.

It's use the plugins too ? if have a plugin using in IMAP, it's use this
same plugin to do the work (ex> expurge, copy,etc) using the hooked rewrited
functions ? Or i need to explict add some configuration in doveadm ?


2010/11/18 Alex Baule 

> Tks timo!
>
> I will take a look in this socket to use it with my schedule.
>
> Em 18/11/2010 16:48, "Timo Sirainen" escreveu:
>
> On Thu, 2010-11-18 at 16:21 -0200, Alex Baule wrote:
> > I will create a schedule to expurge older ema...
> Yes, in that case the dates are looked up from dovecot.index.cache
> files.
>
>
> > Maybe i will create a application that makes a pipe to doveadm and call
> it
> > to do the job.
> BTW. It's possible to talk to doveadm server as well via unix/tcp
> sockets. By default there is $base_dir/doveadm-server unix socket.
>
>
>


Re: [Dovecot] Doveadm

2010-11-18 Thread Alex Baule
Tks timo!

I will take a look in this socket to use it with my schedule.

Em 18/11/2010 16:48, "Timo Sirainen" escreveu:

On Thu, 2010-11-18 at 16:21 -0200, Alex Baule wrote:
> I will create a schedule to expurge older ema...
Yes, in that case the dates are looked up from dovecot.index.cache
files.


> Maybe i will create a application that makes a pipe to doveadm and call it
> to do the job.
BTW. It's possible to talk to doveadm server as well via unix/tcp
sockets. By default there is $base_dir/doveadm-server unix socket.


Re: [Dovecot] Doveadm

2010-11-18 Thread Alex Baule
I will create a schedule to expurge older emails than a date, like 3, 6
months.

Maybe i will create a application that makes a pipe to doveadm and call it
to do the job.



2010/11/18 Timo Sirainen 

> On Thu, 2010-11-18 at 10:08 -0200, Alex Baule wrote:
>
> > How doveadm purge a email ?
>
> By "purge" do you actually mean the "doveadm purge" command that works
> only for multi-dbox? Or I'm guessing more likely you mean "doveadm
> expunge"?
>
> > It's search using the index or scan every directory and open the email to
> > match the search criteria ?
>
> This doesn't have much to do with expunging, or even doveadm really.
> It's done the same way for all doveadm's mail commands (search, fetch,
> expunge, altmove, etc.) The actual search code is also the same as used
> by IMAP SEARCH.
>
> So, yeah, it'll use indexes as best as it can, but if you try to search
> based on something that's not in index/cache file (like message body),
> it'll have to open the mails.
>
>
>


[Dovecot] Doveadm

2010-11-18 Thread Alex Baule
How doveadm purge a email ?

It's search using the index or scan every directory and open the email to
match the search criteria ?


Re: [Dovecot] Mail history function?

2010-11-17 Thread Alex Baule
Sorry, i send a "reply" not a "reply to all"



2010/11/17 Jakob Curdes 

> Please keep replies to the list so that others can participate.
>
>
>
>  I sugest the notify, because the admin can know if a user open a email,
>> copy to another folder, delete the emailetc.
>>
>> but using the MTA it can be a solution too.
>>
>>  At least in Germany, doing this is quite risky as this gives lots of
> information about the person.
> German law limits the use of profiles like these quite strictly; in general
> an employer has no business to log all these actions generally.
> This does not mean it can be helpful for diagnosing problems, but I would
> not recommend to do so as a general procedure.
> On the other hands, it is a de-facto requirement today that you can trace
> every communiction that has entered the company.
> The only place where you can do this without potentiall missing some
> messages is the MTA. This is why all the archival tools want to couple to
> the MTA...
>
> JC
>


Re: [Dovecot] Mail history function?

2010-11-17 Thread Alex Baule
Dovecot have a plugin, called notify

You can use as a base and develop your plugin to write the itens that you
want in the database.

in dovecot source, see in src/plugins/notify

2010/11/17 Oliver Berse 

> I'm a newbie at Dovecot. For a company groupware I need a kind of a
> history function for mails to see which user sent which mail to whom / got
> which mail from whom. So I have to get the message ID of in- and outgoing
> mails (and write related data to a mysql database). My first idea was to
> monitor the log file with a daemon and search for strings like
> "deliver(x...@y.z): 2010-11-15 17:34:56 Info:
> msgid=". I'm not sure
> if this is the right approach. Does anyone know a better solution with
> Dovecot?
>
> thanks,
> Oliver
>


Re: [Dovecot] Trying to building a customized auth plugin

2010-11-16 Thread Alex Baule
Humm... if you get the remote ip, sometimes the PAM don't have this
information to use...

Well...it's better you do the plugin.



2010/11/16 Antonio Perez-Aranda 

> It take login user, pass and other dat from connection like remote ip
> and send to a Java App with special security. If the result of Java
> App is correct (more difficult to explain), then it pass ask to
> standard courier ldap plugin.
>
> 2010/11/16 Alex Baule :
> > What the preauthcustom.c does ? something special or setting some rights
> > from users ?
> >
> > If was only auth, PAM is much more easy
> >
> > 2010/11/16 Antonio Perez-Aranda 
> >
> >> Maybe, but I haven't got any experience with PAM modules as with
> dovecot.
> >>
> >> I have a preauthcustom.c from courier which I have to migrate to
> dovecot.
> >>
> >> 2010/11/16 Alex Baule :
> >> > Dovecot plugins works with hooks. This hooks allow you customize some
> >> > actions.
> >> >
> >> > You need to find the authentication hook, and rewrite it's actions.
> >> >
> >> > Inside the userdb.c have it void userdbs_init(void), but you change
> the
> >> > shared name, so you need to change inside your plugin too.
> >> >
> >> > But, you're trying to do something with auth, you can use PAM, it's
> more
> >> > easy. (i think)
> >> >
> >> > 2010/11/16 Antonio Perez-Aranda 
> >> >
> >> >> Well, all modules start with ifdef like this:
> >> >>
> >> >> #ifdef USERDB_CUSTOM
> >> >>
> >> >> And in this case, this isn't defined. I commet out this ifdef/else/if
> >> >> block and then I have got more errors, I can continure.
> >> >>
> >> >> 2010/11/16 Antonio Perez-Aranda :
> >> >> > Not, userdb-custom and passdb-custom are copies from
> >> >> > userdb-passwd-file and passdb-passwd-file.
> >> >> >
> >> >> > I try with this function now, thanks.
> >> >> >
> >> >> > 2010/11/16 Alex Baule :
> >> >> >> inside your plugin, have this function ? 
> >> >> >>
> >> >> >> Every plugin must have a "init" function and it must call
> >> >> "plugin-name_init"
> >> >> >>
> >> >> >>
> >> >> >> 2010/11/16 Antonio Perez-Aranda 
> >> >> >>
> >> >> >>> Is it needed to include custom db on usedb.c and passdb.c ?
> >> >> >>>
> >> >> >>> I can see at userdb.c:
> >> >> >>>
> >> >> >>> void userdbs_init(void)
> >> >> >>>
> >> >> >>> with all userdb registered, and similar at passdb.c
> >> >> >>>
> >> >> >>>
> >> >> >>> At now, I get the follow line loading the module and trying to
> >> access
> >> >> >>> vía imap login
> >> >> >>>
> >> >> >>> Nov 16 17:54:28 auth: Error: module
> >> >> >>> /usr/lib64/dovecot/auth/libauthdb_custom.so:
> >> dlsym(authdb_custom_init)
> >> >> >>> failed: /usr/lib64/dovecot/auth/libauthdb_custom.so: undefined
> >> symbol:
> >> >> >>> authdb_custom_init
> >> >> >>> Nov 16 17:54:28 auth: Error: Module doesn't have init function:
> >> >> >>> /usr/lib64/dovecot/auth/libauthdb_custom.so
> >> >> >>>
> >> >> >>>
> >> >> >>>
> >> >> >>> 2010/11/16 Antonio Perez-Aranda :
> >> >> >>> > Well, I didn't execute ./configure on $DOVECOT path
> >> >> >>> >
> >> >> >>> > 2010/11/16 Antonio Perez-Aranda :
> >> >> >>> >>  gcc -fPIC -shared -g -Wall \
> >> >> >>> >>  -I$DOVECOT \
> >> >> >>> >>  -I$DOVECOT/src/lib \
> >> >> >>> >>  -I$DOVECOT/src/lib-auth  \
> >> >> >>> >>  -I$DOVECOT/src/lib-sql \
> >> >> >>> >>  -I$DOVECOT/src/lib-settings \
> >> >> >>> >>  -I$DOVECOT/src/lib-ntlm \
> >> >> >>> >>  -I$DOVECOT/src/lib-master \
> >> >> >>> >>  -I$DOVECOT/src/auth \
> >> >> >>> >>  -DHAVE_CONFIG_H \
> >> >> >>> >>  -DAUTH_MODULE_DIR=\"passdb-custom\"\
> >> >> >>> >>  passdb-custom.c -o passdb-custom.o
> >> >> >>> >>
> >> >> >>> >> With this I get:
> >> >> >>> >>
> >> >> >>> >> error on auth-common.h
> >> >> >>> >> ...
> >> >> >>> >> config.h Not found.
> >> >> >>> >>
> >> >> >>> >>
> >> >> >>> >> But config.h are in $DOVECOT path
> >> >> >>> >>
> >> >> >>> >>
> >> >> >>> >> 2010/11/15 Timo Sirainen :
> >> >> >>> >>> On 15.11.2010, at 18.03, Antonio Perez-Aranda wrote:
> >> >> >>> >>>
> >> >> >>> >>>> gcc -fPIC -shared -g -Wall -I$DOVECOT \
> >> >> >>> >>>> -I$DOVECOT/src/lib \
> >> >> >>> >>>> -I$DOVECOT/src/lib-auth  \
> >> >> >>> >>>> -I$DOVECOT/src/lib-sql \
> >> >> >>> >>>> -I$DOVECOT/src/lib-settings \
> >> >> >>> >>>> -I$DOVECOT/src/lib-ntlm \
> >> >> >>> >>>> -I$DOVECOT/src/lib-master \
> >> >> >>> >>>> -I$DOVECOT/src/auth \
> >> >> >>> >>>> passdb-passwd-file.c -o passdb-passwd-file.o
> >> >> >>> >>>>
> >> >> >>> >>>> With this, I get errors relate with uoff_t
> >> >> >>> >>>
> >> >> >>> >>> You need to add -DHAVE_CONFIG_H
> >> >> >>> >>>
> >> >> >>> >>>
> >> >> >>> >>
> >> >> >>> >
> >> >> >>>
> >> >> >>
> >> >> >
> >> >>
> >> >
> >>
> >
>


Re: [Dovecot] Trying to building a customized auth plugin

2010-11-16 Thread Alex Baule
What the preauthcustom.c does ? something special or setting some rights
from users ?

If was only auth, PAM is much more easy

2010/11/16 Antonio Perez-Aranda 

> Maybe, but I haven't got any experience with PAM modules as with dovecot.
>
> I have a preauthcustom.c from courier which I have to migrate to dovecot.
>
> 2010/11/16 Alex Baule :
> > Dovecot plugins works with hooks. This hooks allow you customize some
> > actions.
> >
> > You need to find the authentication hook, and rewrite it's actions.
> >
> > Inside the userdb.c have it void userdbs_init(void), but you change the
> > shared name, so you need to change inside your plugin too.
> >
> > But, you're trying to do something with auth, you can use PAM, it's more
> > easy. (i think)
> >
> > 2010/11/16 Antonio Perez-Aranda 
> >
> >> Well, all modules start with ifdef like this:
> >>
> >> #ifdef USERDB_CUSTOM
> >>
> >> And in this case, this isn't defined. I commet out this ifdef/else/if
> >> block and then I have got more errors, I can continure.
> >>
> >> 2010/11/16 Antonio Perez-Aranda :
> >> > Not, userdb-custom and passdb-custom are copies from
> >> > userdb-passwd-file and passdb-passwd-file.
> >> >
> >> > I try with this function now, thanks.
> >> >
> >> > 2010/11/16 Alex Baule :
> >> >> inside your plugin, have this function ? 
> >> >>
> >> >> Every plugin must have a "init" function and it must call
> >> "plugin-name_init"
> >> >>
> >> >>
> >> >> 2010/11/16 Antonio Perez-Aranda 
> >> >>
> >> >>> Is it needed to include custom db on usedb.c and passdb.c ?
> >> >>>
> >> >>> I can see at userdb.c:
> >> >>>
> >> >>> void userdbs_init(void)
> >> >>>
> >> >>> with all userdb registered, and similar at passdb.c
> >> >>>
> >> >>>
> >> >>> At now, I get the follow line loading the module and trying to
> access
> >> >>> vía imap login
> >> >>>
> >> >>> Nov 16 17:54:28 auth: Error: module
> >> >>> /usr/lib64/dovecot/auth/libauthdb_custom.so:
> dlsym(authdb_custom_init)
> >> >>> failed: /usr/lib64/dovecot/auth/libauthdb_custom.so: undefined
> symbol:
> >> >>> authdb_custom_init
> >> >>> Nov 16 17:54:28 auth: Error: Module doesn't have init function:
> >> >>> /usr/lib64/dovecot/auth/libauthdb_custom.so
> >> >>>
> >> >>>
> >> >>>
> >> >>> 2010/11/16 Antonio Perez-Aranda :
> >> >>> > Well, I didn't execute ./configure on $DOVECOT path
> >> >>> >
> >> >>> > 2010/11/16 Antonio Perez-Aranda :
> >> >>> >>  gcc -fPIC -shared -g -Wall \
> >> >>> >>  -I$DOVECOT \
> >> >>> >>  -I$DOVECOT/src/lib \
> >> >>> >>  -I$DOVECOT/src/lib-auth  \
> >> >>> >>  -I$DOVECOT/src/lib-sql \
> >> >>> >>  -I$DOVECOT/src/lib-settings \
> >> >>> >>  -I$DOVECOT/src/lib-ntlm \
> >> >>> >>  -I$DOVECOT/src/lib-master \
> >> >>> >>  -I$DOVECOT/src/auth \
> >> >>> >>  -DHAVE_CONFIG_H \
> >> >>> >>  -DAUTH_MODULE_DIR=\"passdb-custom\"\
> >> >>> >>  passdb-custom.c -o passdb-custom.o
> >> >>> >>
> >> >>> >> With this I get:
> >> >>> >>
> >> >>> >> error on auth-common.h
> >> >>> >> ...
> >> >>> >> config.h Not found.
> >> >>> >>
> >> >>> >>
> >> >>> >> But config.h are in $DOVECOT path
> >> >>> >>
> >> >>> >>
> >> >>> >> 2010/11/15 Timo Sirainen :
> >> >>> >>> On 15.11.2010, at 18.03, Antonio Perez-Aranda wrote:
> >> >>> >>>
> >> >>> >>>> gcc -fPIC -shared -g -Wall -I$DOVECOT \
> >> >>> >>>> -I$DOVECOT/src/lib \
> >> >>> >>>> -I$DOVECOT/src/lib-auth  \
> >> >>> >>>> -I$DOVECOT/src/lib-sql \
> >> >>> >>>> -I$DOVECOT/src/lib-settings \
> >> >>> >>>> -I$DOVECOT/src/lib-ntlm \
> >> >>> >>>> -I$DOVECOT/src/lib-master \
> >> >>> >>>> -I$DOVECOT/src/auth \
> >> >>> >>>> passdb-passwd-file.c -o passdb-passwd-file.o
> >> >>> >>>>
> >> >>> >>>> With this, I get errors relate with uoff_t
> >> >>> >>>
> >> >>> >>> You need to add -DHAVE_CONFIG_H
> >> >>> >>>
> >> >>> >>>
> >> >>> >>
> >> >>> >
> >> >>>
> >> >>
> >> >
> >>
> >
>


Re: [Dovecot] Trying to building a customized auth plugin

2010-11-16 Thread Alex Baule
Dovecot plugins works with hooks. This hooks allow you customize some
actions.

You need to find the authentication hook, and rewrite it's actions.

Inside the userdb.c have it void userdbs_init(void), but you change the
shared name, so you need to change inside your plugin too.

But, you're trying to do something with auth, you can use PAM, it's more
easy. (i think)

2010/11/16 Antonio Perez-Aranda 

> Well, all modules start with ifdef like this:
>
> #ifdef USERDB_CUSTOM
>
> And in this case, this isn't defined. I commet out this ifdef/else/if
> block and then I have got more errors, I can continure.
>
> 2010/11/16 Antonio Perez-Aranda :
> > Not, userdb-custom and passdb-custom are copies from
> > userdb-passwd-file and passdb-passwd-file.
> >
> > I try with this function now, thanks.
> >
> > 2010/11/16 Alex Baule :
> >> inside your plugin, have this function ? 
> >>
> >> Every plugin must have a "init" function and it must call
> "plugin-name_init"
> >>
> >>
> >> 2010/11/16 Antonio Perez-Aranda 
> >>
> >>> Is it needed to include custom db on usedb.c and passdb.c ?
> >>>
> >>> I can see at userdb.c:
> >>>
> >>> void userdbs_init(void)
> >>>
> >>> with all userdb registered, and similar at passdb.c
> >>>
> >>>
> >>> At now, I get the follow line loading the module and trying to access
> >>> vía imap login
> >>>
> >>> Nov 16 17:54:28 auth: Error: module
> >>> /usr/lib64/dovecot/auth/libauthdb_custom.so: dlsym(authdb_custom_init)
> >>> failed: /usr/lib64/dovecot/auth/libauthdb_custom.so: undefined symbol:
> >>> authdb_custom_init
> >>> Nov 16 17:54:28 auth: Error: Module doesn't have init function:
> >>> /usr/lib64/dovecot/auth/libauthdb_custom.so
> >>>
> >>>
> >>>
> >>> 2010/11/16 Antonio Perez-Aranda :
> >>> > Well, I didn't execute ./configure on $DOVECOT path
> >>> >
> >>> > 2010/11/16 Antonio Perez-Aranda :
> >>> >>  gcc -fPIC -shared -g -Wall \
> >>> >>  -I$DOVECOT \
> >>> >>  -I$DOVECOT/src/lib \
> >>> >>  -I$DOVECOT/src/lib-auth  \
> >>> >>  -I$DOVECOT/src/lib-sql \
> >>> >>  -I$DOVECOT/src/lib-settings \
> >>> >>  -I$DOVECOT/src/lib-ntlm \
> >>> >>  -I$DOVECOT/src/lib-master \
> >>> >>  -I$DOVECOT/src/auth \
> >>> >>  -DHAVE_CONFIG_H \
> >>> >>  -DAUTH_MODULE_DIR=\"passdb-custom\"\
> >>> >>  passdb-custom.c -o passdb-custom.o
> >>> >>
> >>> >> With this I get:
> >>> >>
> >>> >> error on auth-common.h
> >>> >> ...
> >>> >> config.h Not found.
> >>> >>
> >>> >>
> >>> >> But config.h are in $DOVECOT path
> >>> >>
> >>> >>
> >>> >> 2010/11/15 Timo Sirainen :
> >>> >>> On 15.11.2010, at 18.03, Antonio Perez-Aranda wrote:
> >>> >>>
> >>> >>>> gcc -fPIC -shared -g -Wall -I$DOVECOT \
> >>> >>>> -I$DOVECOT/src/lib \
> >>> >>>> -I$DOVECOT/src/lib-auth  \
> >>> >>>> -I$DOVECOT/src/lib-sql \
> >>> >>>> -I$DOVECOT/src/lib-settings \
> >>> >>>> -I$DOVECOT/src/lib-ntlm \
> >>> >>>> -I$DOVECOT/src/lib-master \
> >>> >>>> -I$DOVECOT/src/auth \
> >>> >>>> passdb-passwd-file.c -o passdb-passwd-file.o
> >>> >>>>
> >>> >>>> With this, I get errors relate with uoff_t
> >>> >>>
> >>> >>> You need to add -DHAVE_CONFIG_H
> >>> >>>
> >>> >>>
> >>> >>
> >>> >
> >>>
> >>
> >
>


Re: [Dovecot] Trying to building a customized auth plugin

2010-11-16 Thread Alex Baule
inside your plugin, have this function ? 

Every plugin must have a "init" function and it must call "plugin-name_init"


2010/11/16 Antonio Perez-Aranda 

> Is it needed to include custom db on usedb.c and passdb.c ?
>
> I can see at userdb.c:
>
> void userdbs_init(void)
>
> with all userdb registered, and similar at passdb.c
>
>
> At now, I get the follow line loading the module and trying to access
> vía imap login
>
> Nov 16 17:54:28 auth: Error: module
> /usr/lib64/dovecot/auth/libauthdb_custom.so: dlsym(authdb_custom_init)
> failed: /usr/lib64/dovecot/auth/libauthdb_custom.so: undefined symbol:
> authdb_custom_init
> Nov 16 17:54:28 auth: Error: Module doesn't have init function:
> /usr/lib64/dovecot/auth/libauthdb_custom.so
>
>
>
> 2010/11/16 Antonio Perez-Aranda :
> > Well, I didn't execute ./configure on $DOVECOT path
> >
> > 2010/11/16 Antonio Perez-Aranda :
> >>  gcc -fPIC -shared -g -Wall \
> >>  -I$DOVECOT \
> >>  -I$DOVECOT/src/lib \
> >>  -I$DOVECOT/src/lib-auth  \
> >>  -I$DOVECOT/src/lib-sql \
> >>  -I$DOVECOT/src/lib-settings \
> >>  -I$DOVECOT/src/lib-ntlm \
> >>  -I$DOVECOT/src/lib-master \
> >>  -I$DOVECOT/src/auth \
> >>  -DHAVE_CONFIG_H \
> >>  -DAUTH_MODULE_DIR=\"passdb-custom\"\
> >>  passdb-custom.c -o passdb-custom.o
> >>
> >> With this I get:
> >>
> >> error on auth-common.h
> >> ...
> >> config.h Not found.
> >>
> >>
> >> But config.h are in $DOVECOT path
> >>
> >>
> >> 2010/11/15 Timo Sirainen :
> >>> On 15.11.2010, at 18.03, Antonio Perez-Aranda wrote:
> >>>
>  gcc -fPIC -shared -g -Wall -I$DOVECOT \
>  -I$DOVECOT/src/lib \
>  -I$DOVECOT/src/lib-auth  \
>  -I$DOVECOT/src/lib-sql \
>  -I$DOVECOT/src/lib-settings \
>  -I$DOVECOT/src/lib-ntlm \
>  -I$DOVECOT/src/lib-master \
>  -I$DOVECOT/src/auth \
>  passdb-passwd-file.c -o passdb-passwd-file.o
> 
>  With this, I get errors relate with uoff_t
> >>>
> >>> You need to add -DHAVE_CONFIG_H
> >>>
> >>>
> >>
> >
>


[Dovecot] Getting the Sender from a Email

2010-11-10 Thread Alex Baule
Hi Timo


I need to get the Sender from a Email.

Using this mail_get_first_header(mail, "From", &header) , i get the email in
this format "Name " , in dovecot there is a way to get only the
u...@dom ?

Tks !


Re: [Dovecot] Getting plugin config by user

2010-11-05 Thread Alex Baule
Timo,

the SQL Backend for the ExtraField, have a cache ?

Or if 300 users connects to the IMAP 10 times, the backend will get 300 X 10
connections to the database ?


2010/11/5 Timo Sirainen 

> On Fri, 2010-11-05 at 11:40 -0200, Alex Baule wrote:
> > There is a native way to set/get a configuration to one plugin, to
> various
> > users ?
>
> Return it from userdb:
> http://wiki2.dovecot.org/UserDatabase/ExtraFields#Overriding_settings
>
>
>


[Dovecot] Getting plugin config by user

2010-11-05 Thread Alex Baule
There is a native way to set/get a configuration to one plugin, to various
users ?

Like this:

my_plugin{
  user_a=configurations
  user_b=configurations
  user_..
  user_z=configurations
}

I Have plugin and it can be enable/disabled by user. And i have a lot of
users, like 10 m.

i think if i do like this:

my_plugin {
configurations=user_a,user_b,user,user_z
}

Can get much memory to read every line of configuration...

Tks !


Re: [Dovecot] Know when a Folder is Expunged or Deleted

2010-11-03 Thread Alex Baule
Ok, I will put the hook in delete function.

Tks Timo !



2010/11/3 Timo Sirainen 

> On Wed, 2010-11-03 at 13:09 -0200, Alex Baule wrote:
>
> > I said use the rename, because to delete a folder call the rename
> function,
> > ex(MyFolder --> Trash.MyFolder)
>
> Oh, that. But remember that it's only Thunderbird that does this
> renaming. I'm not aware of any other client that does it, they just
> delete it immediately.
>
>
>


Re: [Dovecot] Know when a Folder is Expunged or Deleted

2010-11-03 Thread Alex Baule
Using the mail_storage_set_error()  works well, i set my messages with
this..!

I said use the rename, because to delete a folder call the rename function,
ex(MyFolder --> Trash.MyFolder)

i will use the mailbox_status() in rename hook, because if i return -1, the
Folder will remain unchanged, and don't be moved to Trash.


2010/11/3 Timo Sirainen 

> On Wed, 2010-11-03 at 09:38 -0200, Alex Baule wrote:
>
> > I try to do what you said, but i can't delete a folder from maildir,
> because
> > the box->opened it's allways true.
>
> It's supposed to be, yes.
>
> > if (!box->opened) {
> > i_warning("Empty Folder...");
>
> No, box->opened doesn't mean it's empty. It means it's not a mailbox at
> all. For example with mbox you could have:
>
> ~/mail/archive/
> ~/mail/archive/2009
>
> Now you would have "archive" directory which would show up as
> box->opened=FALSE, but "archive/2009" would be box->opened=TRUE,
> regardless of how many messages it has.
>
> If you want to check if the mailbox is empty, you need to check for it
> manually with mailbox_status().
>
> > return zbox->super.delete(box);
> > }
> > i_warning("Full Folder...");
> > return -1;
> > }
> >
> > Can i do that in "rename mailbox" function ? If Rename has .Trash in the
> > name, i don't rename and return -1.
>
> I'm not sure what you mean.. Yes, you can cancel a rename operation if
> you want to.
>
> > i Try too, don't let the user "move" one message from any folder to my
> > "quarantine" folder, i intercept the copy function with a hook, but i
> only
> > can do this, returning -1 in the copy function, but with -1 i will get a
> > error message in the client like "Mailbox already exist" if i return 0
> the
> > source email is flaged as Trash and don't show anymore in the source
> > folder... Can i do this, returning some value that works well and dont
> cause
> > a client message ?
>
> Use mail_storage_set_error() before returning -1.
>
>


Re: [Dovecot] Know when a Folder is Expunged or Deleted

2010-11-03 Thread Alex Baule
Hi Timo

I try to do what you said, but i can't delete a folder from maildir, because
the box->opened it's allways true.

This is my hooked function...

static int emexis_mailbox_delete(struct mailbox *box)
{
union mailbox_module_context *zbox = EMEXIS_CONTEXT(box);

if (!box->opened) {
i_warning("Empty Folder...");
return zbox->super.delete(box);
}
i_warning("Full Folder...");
return -1;
}

Can i do that in "rename mailbox" function ? If Rename has .Trash in the
name, i don't rename and return -1.

Another Question...

i Try too, don't let the user "move" one message from any folder to my
"quarantine" folder, i intercept the copy function with a hook, but i only
can do this, returning -1 in the copy function, but with -1 i will get a
error message in the client like "Mailbox already exist" if i return 0 the
source email is flaged as Trash and don't show anymore in the source
folder... Can i do this, returning some value that works well and dont cause
a client message ?

Tks Timo !



2010/11/2 Timo Sirainen 

> On Mon, 2010-11-01 at 14:26 -0200, Alex Baule wrote:
>
> > I intercept the expunge function, to treat my files expunged, but when i
> > expunge a folder, this function it's not called, and my emails don't get
> my
> > treatment to be expunged.
>
> Yeah.. Maybe some day I should change the mailbox deletion to work by
> sending expunge to all mails and then simply removing the empty mailbox.
> This is how it works with multi-dbox, but not with others.
>
> > Basically i need to do something like this:
> >
> > It's empty ? No --> return OK but Dont Delete folder, because it's not
> > empty.
> >   Yes --> Return OK and Delete the Folder to be expunged.
>
> So you want to disallow deleting non-empty folders? Anyway, you need to
> hook into struct mailbox.delete. See quota_mailbox_delete() in quota
> plugin. box->opened=TRUE if it was a real selectable mailbox, while it's
> FALSE if it was simply a directory (Maildir++ has only selectable
> mailboxes).
>
>
>


[Dovecot] Know when a Folder is Expunged or Deleted

2010-11-01 Thread Alex Baule
Hi Timo and Everyone


There is a way to know when a folder it's been deleted ? And if this folder
is empty ?

Let's explain why...

I intercept the expunge function, to treat my files expunged, but when i
expunge a folder, this function it's not called, and my emails don't get my
treatment to be expunged.

Basically i need to do something like this:

It's empty ? No --> return OK but Dont Delete folder, because it's not
empty.
  Yes --> Return OK and Delete the Folder to be expunged.

Tks !


[Dovecot] Doubts with email copying

2010-09-28 Thread Alex Baule
Hi Timo.

Trying to resolve my problem with the references in copying a email between
Folders (when i move from inbox -> sent for example), i got some doubt.

My plugin create a new ostream in v->save_begin, and i start a function from
my library to create the reference, but when the email is been copying, the
new email don't pass in this function, and i don't start my function to
create a reference.

My doubt is, if copying a email is a "copy + paste", why the s->save_begin
it's not called ?

I search in the iostream-internal.h to rewrite some "open stream" but the
only one available is the close.

There is a place to call my function every time that one ostream is opened,
including the copy ?


Re: [Dovecot] get MAIL_FETCH_UIDL_FILE_NAME after save a email

2010-09-23 Thread Alex Baule
I want only the basename, it's the uid without flags.
Em 23/09/2010 17:56, "Timo Sirainen"  escreveu:
> On 23.9.2010, at 21.31, Alex Baule wrote:
>
>> I Try to get the name from the saved email, you said to me, to get this
with
>> the get_special, ok... thats work.
>>
>> I get the name with this:
>> mail_get_special(t->save_ctx->dest_mail, MAIL_FETCH_UIDL_FILE_NAME,
&fname);
>>
>> By i got some mistake... when i save a email that exist in the same
>> directory, the email is rewrited with another name, but the get_special
give
>> me the old one name.
>
> Do you mean the base filename (stuff before ":2,") is different also? The
problem with getting maildir filenames is that the filename changes whenever
flags change, so there are no guarantees that whatever filename you do get
that by the time you try to use it it hasn't already changed. The base
filename stays the same though.
>


[Dovecot] get MAIL_FETCH_UIDL_FILE_NAME after save a email

2010-09-23 Thread Alex Baule
Hi Timo...

I Try to get the name from the saved email, you said to me, to get this with
the get_special, ok... thats work.

I get the name with this:
mail_get_special(t->save_ctx->dest_mail, MAIL_FETCH_UIDL_FILE_NAME, &fname);

By i got some mistake... when i save a email that exist in the same
directory, the email is rewrited with another name, but the get_special give
me the old one name.

Have another way to get the name from a saved email, after save it ?

after this:
ret = zbox->super.transaction_commit(t, changes_r);

To get the correct name from a saved email.


[Dovecot] understand the struct message_header_line

2010-09-21 Thread Alex Baule
Timo...

Using the src/lib-mail/test-istream-header-filter.c as example, and
following your tips to jump my desired header value, but i need to store the
value from the Header filtered.

In the Exemple, the callback is this:

static void filter_callback(struct message_header_line *hdr,
bool *matched, void *context ATTR_UNUSED)
{
if (hdr != NULL && hdr->name_offset == 0) {
/* drop first header */
*matched = TRUE;
}
}

What i try to understand is how the structs work, it's save the entire
header or every line from header call the callback function ?

hdr->name_offset is the size of elements in the struct ? (like a array of
message_header_line)


The void *context ATTR_UNUSED i can pass what i want to change ? like a
pointer to a variable ?


[Dovecot] replace istream and unref the old one...

2010-09-20 Thread Alex Baule
I Build a plugin, that do some stuffs with a email.

To get the input istream, i use the "get_stream" function, like zlib does.

I create a concat_stream, with the full_input[3];

struct istream *full_input[3];

//this like zlib
input = imail->data.stream;

//first input, using the input
full_input[0] = i_stream_create_header_filter(input, HEADER_FILTER_EXCLUDE |
HEADER_FILTER_NO_CR, exclude_headers, 1, filter_callback, imail);
// second input from another file.
full_input[1] = i_stream_create_fd(fd1, 0, TRUE);
// finish the input
full_input[2] = NULL;
// recreating the stream
imail->data.stream = i_stream_create_concat(full_input);
//unref the old one.
i_stream_unref(&input);

return index_mail_init_stream(imail, hdr_size, body_size, stream_r);


I do like zlib, but i got this errors in LOG.
I Think it's because something in the unref, but o don't know what.

Sep 20 10:48:04 brc dovecot: imap(a...@exemplo.com.br): Panic: file
index-mail.c: line 1150 (index_mail_close): assertion failed:
(!mail->data.destroying_stream)
Sep 20 10:48:04 brc dovecot: imap(a...@exemplo.com.br): Error: Raw
backtrace: /opt/addons/lib/dovecot/libdovecot.so.0 [0xb76201ee] ->
/opt/addons/lib/dovecot/libdovecot.so.0 [0xb7620245] ->
/opt/addons/lib/dovecot/libdovecot.so.0 [0xb761f8a6] ->
/opt/addons/lib/dovecot/libdovecot-storage.so.0 [0xb76b568f] ->
/opt/addons/lib/dovecot/libdovecot-storage.so.0(index_mail_free+0x25)
[0xb76b7425] ->
/opt/addons/lib/dovecot/libdovecot-storage.so.0(mail_free+0x12) [0xb76704b2]
-> dovecot/imap(imap_fetch_deinit+0x89) [0x80583e9] -> dovecot/imap
[0x805034d] -> dovecot/imap(cmd_fetch+0x45a) [0x805086a] ->
dovecot/imap(cmd_uid+0x7f) [0x805514f] -> dovecot/imap [0x8055e8c] ->
dovecot/imap [0x8055f3b] -> dovecot/imap(client_handle_input+0x3f)
[0x805608f] -> dovecot/imap(client_input+0x5f) [0x8056a4f] ->
/opt/addons/lib/dovecot/libdovecot.so.0(io_loop_handler_run+0x130)
[0xb762cab0] -> /opt/addons/lib/dovecot/libdovecot.so.0(io_loop_run+0x38)
[0xb762b658] ->
/opt/addons/lib/dovecot/libdovecot.so.0(master_service_run+0x2a)
Sep 20 10:48:04 brc dovecot: master: Error: service(imap): child 11719
killed with signal 6 (core dumps disabled)

Some One can help me ??


[Dovecot] istream_read like zlib, but without zlib

2010-08-31 Thread Alex Baule
Hy Timo !

I Made some modification in stream_read in zlib. I remove all zlib part,
because i don't need this, but i need to read a istream to change it.

Well, i create a size_t called supersize, with is a substitute for
stream->zs.avail_in.

The trouble is, my debug file have a lot of "READ Plugin\n", and i think
it's because my read becomes a loop, i think it's because i don't know to
identify the EOF from the istream.

you can help me to identify the EOF and set it ?

Tks .!!!

static ssize_t i_stream_emx_read(struct istream_private *stream)
{
struct emx_istream *emxstream = (struct emx_istream *)stream;
const unsigned char *data;
uoff_t high_offset;
size_t size;
int ret;


fprintf(emxstream->debug,"READ Plugin\n");
fflush(emxstream->debug);


high_offset = stream->istream.v_offset + (stream->pos - stream->skip);
if (emxstream->eof_offset == high_offset) {
i_assert(emxstream->high_pos == 0);
stream->istream.eof = TRUE;
return -1;
}

if (stream->pos < emxstream->high_pos) {
/* we're here because we seeked back within the read buffer. */
ret = emxstream->high_pos - stream->pos;
stream->pos = emxstream->high_pos;
emxstream->high_pos = 0;
return ret;
}
emxstream->high_pos = 0;

if (stream->pos + CHUNK_SIZE > stream->buffer_size) {
/* try to keep at least CHUNK_SIZE available */
if (!emxstream->marked && stream->skip > 0) {
/* don't try to keep anything cached if we don't
   have a seek mark. */
i_stream_compress(stream);
}
if (stream->max_buffer_size == 0 ||
stream->buffer_size < stream->max_buffer_size)
i_stream_grow_buffer(stream, CHUNK_SIZE);

if (stream->pos == stream->buffer_size) {
if (stream->skip > 0) {
/* lose our buffer cache */
i_stream_compress(stream);
}

if (stream->pos == stream->buffer_size)
return -2; /* buffer full */
}
}

if(emxstream->supersize == 0){
/* need to read more data. try to read a full CHUNK_SIZE */
i_stream_skip(stream->parent, emxstream->prev_size);
if (i_stream_read_data(stream->parent, &data, &size, CHUNK_SIZE-1)
== -1 && size == 0) {
if (stream->parent->stream_errno != 0) {
stream->istream.stream_errno = stream->parent->stream_errno;
} else {
i_assert(stream->parent->eof);
stream->istream.stream_errno = EPIPE;
}
return -1;
}
emxstream->prev_size = size;

if (size == 0) {
/* no more input */
stream->istream.eof = TRUE;
i_assert(!stream->istream.blocking);
return 0;
}

fprintf(emxstream->debug,"READ =|%s|= Plugin\n",data);
fflush(emxstream->debug);

memcpy(stream->w_buffer + stream->pos, data,size);
emxstream->supersize = size;
}


size = stream->buffer_size - stream->pos;
stream->pos += size;

if(stream->istream.eof == TRUE){
emxstream->eof_offset = stream->istream.v_offset + stream->pos;
i_stream_skip(stream->parent, emxstream->prev_size -
emxstream->supersize);
emxstream->supersize = 0;
emxstream->prev_size = 0;
}

if (size == 0) {
/* read more input */
return i_stream_emx_read(stream);
}
return size;
}


Re: [Dovecot] Plugin Handle input messages

2010-07-22 Thread Alex Baule
Hi Timo

Let's try to work with my plugin !

I Try to do this in "save_begin"

static int
emexis_mail_save_encrypted_begin(struct mail_save_context *ctx,
  struct istream *input)
{
struct mailbox *box = ctx->transaction->box;
struct emexis_user *zuser = EMEXIS_USER_CONTEXT(box->storage->user);
union mailbox_module_context *zbox = EMEXIS_CONTEXT(box);
struct ostream *output;
struct istream *new_input;

/* This is when a try to change the INPUT stream to include my header
line */
new_input =* i_stream_create_emx*(input);
if (zbox->super.save_begin(ctx, new_input) < 0)
return -1;
i_stream_unref(&new_input);
/* END INPUT modification */

 /* This part is to handle the saved email like zlib do, and works ! */
zuser->writer =  emexis_uis_init(zuser->mountPoint, zuser->save_mail,
zuser->kSize, zuser->kValue, zuser->userAuth);
output = o_stream_create_emexis(ctx->output, &zuser->writer, input);
o_stream_unref(&ctx->output);
ctx->output = output;
o_stream_cork(ctx->output);
/* END handle saved email */

return 0;
}

The i_stream_create_emx is basically the istream-zlib.c  modifed, (i use it
to read my splited email from file, and works fine).

Theoretically, the emexis_mail_save_encrypted_begin is right, calling my
i_stream_create_emx correctly.

I got some error in read function:

Panic: file istream-add_header.c: line 125 (i_stream_emx_read): assertion
failed: (ret > 0)
Jul 21 14:50:49 brc dovecot: imap(a...@exemplo.com.br): Error: Raw
backtrace: /opt/addons/lib/dovecot/libdovecot.so.0 [0xb76d4a8e] ->
/opt/addons/lib/dovecot/libdovecot.so.0 [0xb76d4ae5] ->
/opt/addons/lib/dovecot/libdovecot.so.0 [0xb76d4146] ->
/opt/addons/lib/dovecot/lib20_emexis_uis_plugin.so [0xb73ade62] ->
/opt/addons/lib/dovecot/libdovecot.so.0(i_stream_read+0x7a) [0xb76db0da] ->
/opt/addons/lib/dovecot/libdovecot.so.0 [0xb76dcab6] ->
/opt/addons/lib/dovecot/libdovecot.so.0 [0xb76dcb8c] ->
/opt/addons/lib/dovecot/libdovecot.so.0(i_stream_read+0x7a) [0xb76db0da] ->
/opt/addons/lib/dovecot/libdovecot.so.0 [0xb76df5fc] ->
/opt/addons/lib/dovecot/libdovecot.so.0(i_stream_read+0x7a) [0xb76db0da] ->
/opt/addons/lib/dovecot/libdovecot.so.0(i_stream_read_data+0x2b)
[0xb76db35b] -> /opt/addons/lib/dovecot/libdovecot.so.0(io_stream_copy+0x5d)
[0xb76e7f1d] -> /opt/addons/lib/dovecot/libdovecot.so.0 [0xb76e7fc0] ->
/opt/addons/lib/dovecot/libdovecot.so.0(o_stream_send_istream+0x4b)
[0xb76e820b] -> /opt/addons/lib

my read is like this:


do {
ret = read(emx_stream->fd ,stream->w_buffer + stream->pos, size);
fprintf(emx_stream->debug,"RET FROM READ = %d -- ERRNO = %d -- STR =
|%s|\n", ret, errno, strerror(errno));
} while (ret < 0 && errno == EINTR && stream->istream.blocking);

if (ret == 0 ) {
/* EOF */
stream->istream.eof = TRUE;
fprintf(emx_stream->debug,"EOF EOF EOF TRUE\n");
return -1;
}

if (ret < 0) {
if (errno == EAGAIN) {
i_assert(!stream->istream.blocking);
ret = 0;
}
}

fprintf(emx_stream->debug,"READ RET = %d -- ERRNO = %d -- STR = |%s|\n",
ret, errno, strerror(errno));
fprintf(emx_stream->debug,"stream->pos = %d -- emx_stream->seek_offset =
%d\n", stream->pos, emx_stream->seek_offset);

emx_stream->seek_offset += ret;
stream->pos += ret;

i_assert(ret > 0); // The error is here.

fprintf(emx_stream->debug,"READ RET DECRYPT  = %d -- stream->pos = %d --
emx_stream->seek_offset = %d\n", ret, stream->pos, emx_stream->seek_offset);
fprintf(emx_stream->debug,"** FINISH READ
*\n");
fflush(emx_stream->debug);

return ret;


There is some wrong in read like this ?

The better to do is copy the istream.c and change the funcions name to do
the same thing, and add my header line ?




2010/6/26 Alex Baule 

> I will try to do like you said, and i will return later to said the result
> !
>
> Tks.
>
> 2010/6/25 Timo Sirainen 
>
> On Mon, 2010-06-21 at 16:43 -0300, Alex Baule wrote:
>> > if (imail->data.stream != NULL ||
>> >(_mail->uid == 0 && zuser->save_handler == NULL)) {
>> >return zmail->super.get_stream(_mail, hdr_size, body_size,
>> >   stream_r);
>> >}
>> >
>> > I think this is the line that return the stream that is the stream sent
>> by
>> > client.
>> >
>> > I try to change this line and put inside this IF , a call to my function
>> to
>> > handle with the input email from client. But i g

Re: [Dovecot] Help with some features to do in a plugin

2010-07-22 Thread Alex Baule
Tks Timo !

It's sound like easy to do !

2010/7/22 Timo Sirainen 

> On Thu, 2010-07-22 at 15:01 -0300, Alex Baule wrote:
>
> > I need to develop some plugins, but i can't know if is possible to do or
> > not.
> >
> > 1 - There is a way to deny a email to be moved from one folder to another
> ?
> > example:
> > the user is only allowed to move mails in Spam Folder to Trash Folder.
> >
> > If yes, were i can find a code example or a plugin to extract some idea.
>
> There is no "move" feature in IMAP or Dovecot, only copy+delete. For
> example ACL plugin can deny saves and copies to a mailbox.
>
> Anyway, override mailbox.copy() and return -1 if you don't like the
> source or destination mailbox. You can hook into that from
> hook_mailbox_allocated, similar to many plugins override e.g.
> mailbox.transaction_begin().
>
> > 2 - It's possible to deny a user to create a subscription folder ?
>
> Override mailbox.create() and return -1 if you don't want it created.
> Hook the same way as copy().
>
>


[Dovecot] Help with some features to do in a plugin

2010-07-22 Thread Alex Baule
Hello Everyone


I need to develop some plugins, but i can't know if is possible to do or
not.

1 - There is a way to deny a email to be moved from one folder to another ?
example:
the user is only allowed to move mails in Spam Folder to Trash Folder.

If yes, were i can find a code example or a plugin to extract some idea.

2 - It's possible to deny a user to create a subscription folder ?
example:
with autocreate plugin, i create a Spam Folder, but if the autocreate is not
configured to this user, it can't create manually this same folder.

If yes, were i can find a code example or a plugin to extract some idea.


Tks !


Re: [Dovecot] Expunge email Plugin

2010-06-29 Thread Alex Baule
Great... its work

Now i need a header value too, i see in mail_log plugin, some functions to
get headers value...

but it's a enum with some know fields.

There is some function like this mail_get_special, to get a header value ?

like "get_header_value(mail,"HEADERFIELD", &value);" ??



2010/6/29 Timo Sirainen 

> On Sat, 2010-06-26 at 12:59 -0300, Alex Baule wrote:
> > I use the notify plugin as a base to my plugin.
> >
> > So, i need the filename from the expunged mail, to use to search my other
> > file to erase.
> >
> > What's the way to find the filename ? I thy to get by i_stream_get_name,
> but
> > i'm lost with the input istream to get this.
>
> This gives you the base filename:
>
> mail_get_special(mail, MAIL_FETCH_UIDL_FILE_NAME, &fname)
>
>
>


Re: [Dovecot] Plugin Handle input messages

2010-06-26 Thread Alex Baule
I will try to do like you said, and i will return later to said the result !


Tks.

2010/6/25 Timo Sirainen 

> On Mon, 2010-06-21 at 16:43 -0300, Alex Baule wrote:
> > if (imail->data.stream != NULL ||
> >(_mail->uid == 0 && zuser->save_handler == NULL)) {
> >return zmail->super.get_stream(_mail, hdr_size, body_size,
> >   stream_r);
> >}
> >
> > I think this is the line that return the stream that is the stream sent
> by
> > client.
> >
> > I try to change this line and put inside this IF , a call to my function
> to
> > handle with the input email from client. But i got some errors about the
> > input part.
>
> I'm not really sure what you mean by this. What input are you sending
> where? Show some example non-working code?
>
> > In other email, Timo said, to get the S and W flags in the email name, i
> > need to intercept the email input from client to dovecot, in this part is
> > done the W and S calculation.
> >
> > Timo, where is the part that i can get the input from client ?
>
> IIRC you wanted to add some extra headers to the mail (and you wanted it
> to be visible to clients, right? if not, you could do it similarly than
> how mbox hides some headers). All mails are saved via:
>
> int mailbox_save_begin(struct mail_save_context **ctx, struct istream
> *input);
>
> And the input comes from there. You need to replace that input with your
> own input stream that contains the wanted headers and other changes
> (probably something built with istream-concat and
> istream-header-filter). You can replace the input by overriding
> mailbox.save_begin() method, for example see acl plugin how it uses
> acl_save_begin(). Maybe something like:
>
> static int
> your_save_begin(struct mail_save_context *ctx, struct istream *input)
> {
>struct mailbox *box = ctx->transaction->box;
>struct your_mailbox *abox = YOUR_CONTEXT(box);
>struct istream *new_input;
>int ret;
>
>new_input = build_changed_input(input);
>ret = abox->module_ctx.super.save_begin(ctx, new_input);
>i_stream_unref(&new_input);
>return ret;
> }
>
>
>


Re: [Dovecot] Expunge email Plugin

2010-06-26 Thread Alex Baule
I use the notify plugin as a base to my plugin.

So, i need the filename from the expunged mail, to use to search my other
file to erase.

What's the way to find the filename ? I thy to get by i_stream_get_name, but
i'm lost with the input istream to get this.

2010/6/25 Timo Sirainen 

> On Mon, 2010-06-21 at 17:27 -0300, Alex Baule wrote:
> > Hello everyone.
> >
> >
> > I Need to know when a email is expunge, but i don't need change this
> action.
> > I Need to call another action + the default action.
> >
> > There is a plugin to do this ?
>
> In v2.0 there is a notify plugin which you can pretty easily use to
> catch expunge events. mail_log plugin also uses it.
>
>
>


[Dovecot] Expunge email Plugin

2010-06-21 Thread Alex Baule
Hello everyone.


I Need to know when a email is expunge, but i don't need change this action.
I Need to call another action + the default action.

There is a plugin to do this ?


[Dovecot] Plugin Handle input messages

2010-06-21 Thread Alex Baule
Hi Timo


I try to change my plugin to read the input email to increase a header line
and one \r\n.

But i need help to get this input

My plugin is based in zlib plugin.

In "static int zlib_permail_get_stream" function, have it.


if (imail->data.stream != NULL ||
   (_mail->uid == 0 && zuser->save_handler == NULL)) {
   return zmail->super.get_stream(_mail, hdr_size, body_size,
  stream_r);
   }

I think this is the line that return the stream that is the stream sent by
client.

I try to change this line and put inside this IF , a call to my function to
handle with the input email from client. But i got some errors about the
input part.

In other email, Timo said, to get the S and W flags in the email name, i
need to intercept the email input from client to dovecot, in this part is
done the W and S calculation.

Timo, where is the part that i can get the input from client ?


Re: [Dovecot] Zlib plugin dovecot 2.0beta4

2010-05-26 Thread Alex Baule
Mostrar romanização
The extra line added to the header is to maintain compatibility with
SMTP(share library code), which already works well. Besides having other
benefits that are due to the hash in the header.

I tried accessing the same way that istream is done in the zlib (
zlib_permail_get_stream ), where the reference to mail-> uid == 0, (nonzero
is to read the file -> dovecot).


if (imail->data.stream != NULL || (_mail->uid == 0 && zuser->disable_uis ==
1)) { //disable_uis ir read like the zlib_save variable , if is not present
, we don't need to get stream, and works like no modifications.
  return zmail->super.get_stream(_mail, hdr_size, body_size, stream_r);
}else if (imail->data.stream != NULL || _mail->uid == 0 ) { // OK, its a
istream from received email.
  input = imail->data.stream;
  imail->data.stream = i_stream_create_emx(input);
}



But I do not know if it is correct.

If you can tell me where is exactly the way or the point that i must catch
the istream input, i do the rest.

Tks Timo !




2010/5/26 Timo Sirainen 

> On Tue, 2010-05-11 at 16:41 -0300, Alex Baule wrote:
>
> > But i need to get / change some values to create the "link" from header
> to
> > body.
> >
> > When a email is saved, have the S an W flags, that is the size of email.
> > There is a way to increase this Flags ?  I need to put one more line in
> the
> > header, to have some link to body.
>
> So you want to add one header and have the S/W increase the number? The
> problem isn't only the S/W, it's also that Dovecot saves the message
> size to cache file. The only good way to solve this is to change your
> input stream to return the header, so that all of Dovecot's internal
> code sees it and internally adds them to the S/W/cache.
>
> But do you really even need a header for the link? Maybe you could just
> use IMAP UID number? Like if you have ~/Maildir/.foo/cur/abcd:2, file
> with UID=200, its body could be in e.g. ~/Maildir/.foo/body/200.
>
>
>


Re: [Dovecot] [SOLVED] %d is empty in mail_location

2010-05-14 Thread Alex Baule
Add in your auth,conf configuration:

auth_default_realm = [your domain]

2010/5/14 Phil Howard 

> On Mon, May 10, 2010 at 15:21, Phil Howard  wrote:
>
> > I have this in dovecot-postfix.conf:
> >
> > mail_location =
> >
> maildir:/home/mail/dnamesum=%12MLd/dname=%Ld/unamesum=%12MLn/uname=%Ln/mail
> >
> > Yes, it is excessive, but that's just for testing.  The pattern I really
> > want is less clear for debugging.  In postfix/main.cf I have:
> >
> > mailbox_command = /usr/lib/dovecot/deliver -c
> > /etc/dovecot/dovecot-postfix.conf -a "${RECIPIENT}"
> >
> > I verified through strace that -a "${RECIPIENT}" is in fact getting a
> full
> > u...@domain address.  The problem is that %d and %Ld are coming up as
> > empty, and %12MLd is giving me the first 12 hex characters of an md5 of
> an
> > empty content.  It's losing the domain name somewhere.  It's in the mail
> > headers and in the -a option.  So what else is needed?
> >
>
> There was a typo in an earlier config item:
>
> auth_username_format = %...@ld
>
> Maybe that was what someone was screaming at me about when I looked at
> username_format.  I didn't see this until I was trying to figure out why
> the
> passwd file wasn't being read.  I ran strace, and saw that it was trying to
> access a file with "ld" in it.  Even then it took a while because the
> domain
> had been reformed as "Ld" and subsequently lower cased later.
>
> I found this while trying out a subset of a couple suggested configurations
> with some virtual_* settings in Postfix, and using dovecot/deliver via
> transport.
>
> I will now clean up the mess and hope I don't break it doing that.  Then
> slam it with email and see what happens next.
>


[Dovecot] Zlib plugin dovecot 2.0beta4

2010-05-11 Thread Alex Baule
Hi Timo...

I made the plugin like you say.

The header part is saved by dovecot, with o_stream_send , and the body with
my function.

This implementation, works fine.

But i need to get / change some values to create the "link" from header to
body.

When a email is saved, have the S an W flags, that is the size of email.
There is a way to increase this Flags ?  I need to put one more line in the
header, to have some link to body.

To Increase the S Flag i increase the ostream.offset, but the W is based in
the offset from istream, that's right ?

There is a way to do this without rewrite the read function !? Exemple, when
the email is moved from tmp to cur.


[Dovecot] Bug in zlib Plugin (2.0)

2010-05-06 Thread Alex Baule
Hello everyone.


I Made some tests in zlib plugin, and in ostream file (ostream-zlib.c) in
o_stream_zlib_sendv function, have it:

stream->ostream.offset += bytes;

In struct mail_save_context, have saved_physical_size and it can be updated,
acording with the observation.

/* if non-zero, overrides the physical size that should be saved.
  for example when using zlib plugin, this would contain the mail's
  uncompressed size. */
   uoff_t saved_physical_size;


in file zlib-plugin.c in zlib_mail_save_compress_finish function, have it:

ctx->saved_physical_size = ctx->output->offset;

It's a update to offset (the size of email) in zlib, but if you update this
value with a new number, the W flag in email is NOT updated.

This is the original file, without update the or increase offset.
1273155226.M512158P16310.brc,S=435,W=390:2,S


This is the file updated with 5000b more.

1273155226.M512158P16310.brc,S=5435,W=390:2,S

The S is updated, but W not.

OK, this not matter in zlib plugin, because the physical size is the email
uncompressed, but if you use the zlib as example, and you use this value
(saved_physical_size) to update your saved email size, it can't update the W
flag, and the email will not be open, because the W size is wrong.


[Dovecot] Plugin to handle message saved and handle move from tmp to cur/new

2010-05-05 Thread Alex Baule
Hello everyone

I need to finish my plugin, but i depends from some stuffs in the save/move
process that i can't find how its work.

In new zlib plugin (2.0) , the message is saved compressed now, but i dont
find how is done the process to write the file to tmp, and move it to the
cur or new directory (inside .Sent).

I need to hook this function, to get access to some variables, like Flags
and filename.

There is a way to do this ?

Tks.


Re: [Dovecot] zlib Plugin Dovecot 2.0 - ostream

2010-05-03 Thread Alex Baule
Hi Timo...

I made the plugin like you say.

The header part is saved by dovecot, with o_stream_send , and the body with
my function.

This implementation, works fine.

But i need to get / change some values to create the "link" from header to
body.

When a email is saved, have the S an W flags, that is the size of email.
There is a way to increase this Flags ?  I need to put one more line in the
header, to have some link to body.

The second is, the name of file.

I use the o_stream_get_name, passing the output ostream, but the return is
empty. The name is avaliable when ?

Tks Timo.


2010/4/20 Timo Sirainen 

> You should write the message header to the ostream that you get, and
> message body to some other file that you create. Use the o_stream_send()
> function to write the message header to the ostream (which does
> basically the same as write(fd)). I don't see how getting the stream's
> fd would help with anything.
>
> On Tue, 2010-04-20 at 11:54 -0300, Alex Baule wrote:
> > Because my plugin will separate the body of the message header.
> >
> > With the FD I have control over the message to separate it.
> >
> > Do you have any suggestions for this separation?
> >
> > I do not quite understand how the struct ostream works.
> >
> > Tks Timo.
> >
> >
> >
> > 2010/4/20 Timo Sirainen 
> >
> > > On Tue, 2010-04-20 at 11:40 -0300, Alex Baule wrote:
> > >
> > > > There is a way to get the file descriptor from output used in ostream
> > > zlib
> > > > plugin ?
> > >
> > > No. Why do you need it? You should be writing to ostream, not to its
> fd.
> > >
> > >
>
>


[Dovecot] zlib Plugin Dovecot 2.0 - ostream

2010-04-30 Thread Alex Baule
Hello Everyone.

There is possible to rename the email saved by a plugin, like zlib ?

i explain i need to add 1 line in email header, because of that, i want
to rewrite the filename to update the S and W flag.

Tks !


[Dovecot] zlib plugin dovecot 2.0 - write email

2010-04-26 Thread Alex Baule
Hello Everyone.

There is possible to rename the email writed by a plugin, like zlib ?

i explain i need to add 1 line in email header, because of that, i want
to rewrite the filename to update the S and W flag.

Tks !


Re: [Dovecot] zlib Plugin Dovecot 2.0 - ostream

2010-04-22 Thread Alex Baule
Hi Timo


I'm doing the plugin based on what you said.

But I'll add a line in the message header,  so the S and W (size of email)
flags, on the file name has to be changed ... There is a way  to do that in
the plugin?


2010/4/20 Alex Baule 

> If I had the file descriptor, I will reuse my functions to do this,  made
> in a separate library, that i use in the MTA.
>
> So no need to rewrite again the part of split the message.
>
>
>
> 2010/4/20 Timo Sirainen 
>
>> You should write the message header to the ostream that you get, and
>> message body to some other file that you create. Use the o_stream_send()
>> function to write the message header to the ostream (which does
>> basically the same as write(fd)). I don't see how getting the stream's
>> fd would help with anything.
>>
>> On Tue, 2010-04-20 at 11:54 -0300, Alex Baule wrote:
>> > Because my plugin will separate the body of the message header.
>> >
>> > With the FD I have control over the message to separate it.
>> >
>> > Do you have any suggestions for this separation?
>> >
>> > I do not quite understand how the struct ostream works.
>> >
>> > Tks Timo.
>> >
>> >
>> >
>> > 2010/4/20 Timo Sirainen 
>> >
>> > > On Tue, 2010-04-20 at 11:40 -0300, Alex Baule wrote:
>> > >
>> > > > There is a way to get the file descriptor from output used in
>> ostream
>> > > zlib
>> > > > plugin ?
>> > >
>> > > No. Why do you need it? You should be writing to ostream, not to its
>> fd.
>> > >
>> > >
>>
>>
>


Re: [Dovecot] zlib Plugin Dovecot 2.0 - ostream

2010-04-20 Thread Alex Baule
If I had the file descriptor, I will reuse my functions to do this,  made in
a separate library, that i use in the MTA.

So no need to rewrite again the part of split the message.


2010/4/20 Timo Sirainen 

> You should write the message header to the ostream that you get, and
> message body to some other file that you create. Use the o_stream_send()
> function to write the message header to the ostream (which does
> basically the same as write(fd)). I don't see how getting the stream's
> fd would help with anything.
>
> On Tue, 2010-04-20 at 11:54 -0300, Alex Baule wrote:
> > Because my plugin will separate the body of the message header.
> >
> > With the FD I have control over the message to separate it.
> >
> > Do you have any suggestions for this separation?
> >
> > I do not quite understand how the struct ostream works.
> >
> > Tks Timo.
> >
> >
> >
> > 2010/4/20 Timo Sirainen 
> >
> > > On Tue, 2010-04-20 at 11:40 -0300, Alex Baule wrote:
> > >
> > > > There is a way to get the file descriptor from output used in ostream
> > > zlib
> > > > plugin ?
> > >
> > > No. Why do you need it? You should be writing to ostream, not to its
> fd.
> > >
> > >
>
>


Re: [Dovecot] zlib Plugin Dovecot 2.0 - ostream

2010-04-20 Thread Alex Baule
Because my plugin will separate the body of the message header.

With the FD I have control over the message to separate it.

Do you have any suggestions for this separation?

I do not quite understand how the struct ostream works.

Tks Timo.



2010/4/20 Timo Sirainen 

> On Tue, 2010-04-20 at 11:40 -0300, Alex Baule wrote:
>
> > There is a way to get the file descriptor from output used in ostream
> zlib
> > plugin ?
>
> No. Why do you need it? You should be writing to ostream, not to its fd.
>
>


[Dovecot] zlib Plugin Dovecot 2.0 - ostream

2010-04-20 Thread Alex Baule
Hello Everyone...

In zlib save mail have it:

struct ostream *output;

There is a way to get the file descriptor from output used in ostream zlib
plugin ?

to get in istream is i_stream_get_fd, but don't have o_stream_get_fd..


Re: [Dovecot] zlib Plugin Dovecot 2.0

2010-04-16 Thread Alex Baule
Ok !

That's easy.

In the sendv rewrite, have this:

 for (i = 0; i < iov_count; i++) {
   if (o_stream_emexis_send_chunk(emexis_stream, iov[i].iov_base,
iov[i].iov_len) < 0)
   return -1;
   bytes += iov[i].iov_len;
   }

This iov is every line from the new emaill to save ?

Or this is a email block with X bytes ?

In my function to write email, i split the email by \n, to save it splited,
and if the iov is splited by \n, is good for me.


2010/4/16 Timo Sirainen 

> On Fri, 2010-04-16 at 18:34 +0300, Timo Sirainen wrote:
> > On Fri, 2010-04-16 at 09:55 -0300, Alex Baule wrote:
> >
> > > Part of reading I already migrated, only that the piece of writing (the
> new
> > > part in the plugin) I need to understand some things about the
> operation in
> > > order to migrate and redo the same functions with the separation of
> body /
> > > header
> >
> > So you also want to add support for the split operating directly during
> > saving new mails?
> >
> > I guess you can copy&paste most of the code from zlib-plugin.c and just
> > implement a new ostream. ostream-bzlib.c should give a good example. You
> > just need to implement:
>
> Oh, and the output ostream that you get from create() is the one that
> ends up in the maildir. So I guess you should be writing headers there,
> and write the body to another file some other way.
>
>


Re: [Dovecot] zlib Plugin Dovecot 2.0

2010-04-16 Thread Alex Baule
Thanks Timo,

I have another question about the plugin.

Part of reading I already migrated, only that the piece of writing (the new
part in the plugin) I need to understand some things about the operation in
order to migrate and redo the same functions with the separation of body /
header

Can you explain to me ?

Tks again !



2010/4/16 Timo Sirainen 

> On Fri, 2010-04-09 at 11:42 -0300, Alex Baule wrote:
>
> > I developed a plugin based on the zlib plugin, but want to port it to
> > dovecot 2.0.
> >
> > There are some differences in the 2.0 plugin, which I did not quite
> > understand how it works for me to readjust it in my plugin.
>
> I don't think you need to do (almost?) any changes. v2.0's zlib plugin
> is very different from v1.x, but that's because I'm using zlib library
> in a different way. Not because of some istream changes.
>
>


Re: [Dovecot] default domain empty

2010-04-14 Thread Alex Baule
Yes..

This is from auth.conf (dovecot 2.X)

# Default realm/domain to use if none was specified. This is used for both
# SASL realms and appending @domain to username in plaintext logins.
#auth_default_realm =

so, if you put in auth_default_realm, your default domain, it will append
this to the username.


2010/4/14 Leo Unglaub 

> Hi friends,
> i have a question. I have a running dovecot install on my server and a
> lot of virtual domains. It works great. The users are logging in with
> u...@domain.tld but one old domain must be logged in with only the
> username only (without @domain.tld). My problem is that in this case
> the mailbox_localtion don't work. For example:
> > mail_location =
> maildir:/var/mail/%d/%n/maildir:INDEX=/var/mail/%d/%n/indizies
> The variable %d is not replaced with the domain. The dokumentation
> says: domain part in u...@domain, empty if user there's no domain
> Okay, but is there a way to add a domain to this beause i need the %%d
> for mailbox sharing.
>
> Can i override the domain with a value from the user db or is it
> possible with a login script or somethink?
> Thank you a lot
> Greetings from Austria
> Leo
>


Re: [Dovecot] zlib Plugin Dovecot 2.0

2010-04-09 Thread Alex Baule
Hi Paschal

You do not understand what I want.

I developed a plugin based on the zlib plugin, but want to port it to
dovecot 2.0.

There are some differences in the 2.0 plugin, which I did not quite
understand how it works for me to readjust it in my plugin.

As in the source code there are not many comments, I do not quite know what
each function does, if they are all necessary in my adaptation.

In developing the plugin in version 1.4, Timo helped me a lot.

What I need to know is how the hooks on write emails do this,  and what the
differences in the read function, since the code is different from version
1.4 to 2.0.


2010/4/9 Alex Baule 

> I Dont want the configuration.
>
> I Want know how is implemented.
>
> Explain, the functions, the hooks to get write a email
>
> stuffs like this.
>
> 2010/4/8 Alex Baule 
>
> Hi Everyone
>>
>> Someone can explain to me the difference from zlib 1.2.X and 2.0 beta4 ??
>>
>> In zlib from 2.0 beta4, Which part of the plugin is responsible for write
>> the compressed message ?
>>
>>
>>
>


Re: [Dovecot] zlib Plugin Dovecot 2.0

2010-04-09 Thread Alex Baule
Hi Paschal

You do not understand what I want.

I developed a plugin based on the zlib plugin, but want to port it to
dovecot 2.0.

There are some differences in the 2.0 plugin, which I did not quite
understand how it works for me to readjust it in my plugin.

As in the source code there are not many comments, I do not quite know what
each function does, if they are all necessary in my adaptation.

In developing the plugin in version 1.4, Timo helped me a lot.

What I need to know is how the hooks on write emails do this,  and what the
differences in the read function, since the code is different from version
1.4 to 2.0.


Re: [Dovecot] zlib Plugin Dovecot 2.0

2010-04-09 Thread Alex Baule
I Dont want the configuration.

I Want know how is implemented.

Explain, the functions, the hooks to get write a email

stuffs like this.

2010/4/8 Alex Baule 

> Hi Everyone
>
> Someone can explain to me the difference from zlib 1.2.X and 2.0 beta4 ??
>
> In zlib from 2.0 beta4, Which part of the plugin is responsible for write
> the compressed message ?
>
>
>


[Dovecot] zlib Plugin Dovecot 2.0

2010-04-08 Thread Alex Baule
Hi Everyone

Someone can explain to me the difference from zlib 1.2.X and 2.0 beta4 ??

In zlib from 2.0 beta4, Which part of the plugin is responsible for write
the compressed message ?


[Dovecot] Get plugins configuration in dovecot 2.0

2010-03-30 Thread Alex Baule
In 1.X to get configuration Timo said.

In v1.x they're in environment variables. So if you have:

plugin {
 foo = bar
}

getenv("FOO") returns "bar".

But, in 2.0 ?!

getenv dont work


[Dovecot] What is the difference between the plugin zlib and imap-zlib ?

2010-03-24 Thread Alex Baule
What is the difference between the plugin zlib and imap-zlib ?

in dovecot 1.2.X the zlib plugin works with imapimap-zlib is a
complement to zlib ?


[Dovecot] Plugin like zlib

2010-03-12 Thread Alex Baule
Hi everyone.

I rebuild a plugin, based on zlib plugin.
The changes between this plugin and zlib, is the zlib stuffs is replaced by
open, read, lseek, close.
With "plain-text" files, its works ok.
So, my file is encrypt, and the result from decrypt file is different from
fread.
Like zlib, i read from fread the size variable, but the value added in
seek_offset and pos is the result from decrypt, and it can be dfferent from
fread.
Like zlib, my file size is different from email. In zlib the file is smaller
than the email. In my file, the file is bigger than the email.

OK, lets go to the problem now.

when the email arrives in the new folder,  by imap, the stat (read my file
by "while (i_stream_emexis_read(stream) > 0)" like zlib) and the seek works
finethe email is readed and the final stat size is the decrypted size of
my email (smaller than original file).

When I receive the email, clicking in "Send/Receive", The read function is
aborted because the size to read (like zlib) is negative. I put some debug
in my plugin, and print some stuffs about the functions.

Email decryt size =   49556
Email encrypt size = 49568

Attachements:
mail-arrived, is when the email arrives, and it's ok the read.
mail-receive, is when the email is received, and have the error.
maillog is the /var/log/mail


The bigger difference from zlib is the i_stream_zlib_read part

do {
ret = read(zstream->fd ,crypttext, size);
fprintf(zstream->debug,"DENTRO DA READ RET = %d -- ERRNO = %d -- STR
= |%s|\n", ret, errno, strerror(errno));
if(ret > 0){
EVP_DecryptUpdate(&ctx, plaintext, &plain_len, crypttext, ret);
memcpy(stream->w_buffer + stream->pos , plaintext, plain_len);

bzero (plaintext, DEFAULT_MAX_BUFFER_SIZE);
EVP_DecryptFinal(&ctx, plaintext, &plain_len_final);
memcpy(stream->w_buffer + stream->pos + plain_len , plaintext,
plain_len_final);
}
} while (ret < 0 && errno == EINTR && stream->istream.blocking);

*retc *=  plain_len + plain_len_final;

if (ret == 0 ) {
/* EOF */
stream->istream.eof = TRUE;
return -1;
}

if (ret < 0) {
if (errno == EAGAIN) {
i_assert(!stream->istream.blocking);
ret = 0;
//  } else {
//  i_assert(errno != 0);
//  stream->istream.stream_errno = errno;
//  return -1;
}
}

fprintf(zstream->debug,"READ RET = %d -- ERRNO = %d -- STR = |%s|\n",
ret, errno, strerror(errno));
fprintf(zstream->debug,"stream->pos = %d -- zstream->seek_offset =
%d\n", stream->pos, zstream->seek_offset);

zstream->seek_offset += *retc*;
stream->pos += *retc*;

i_assert(ret > 0);

fprintf(zstream->debug,"READ RET DECRYPT  = %d -- stream->pos = %d --
zstream->seek_offset = %d\n", ret, stream->pos, zstream->seek_offset);
fprintf(zstream->debug,"** FINISH READ
*\n");
fflush(zstream->debug);

return *retc;*


The* retc* is the result from decrypt.

In mail-receive file (line 38), there is the error, at some point along the
read/send email, the stream->pos (its returned by i_stream_compress, with
stream->pos -= stream->skip) is changed out from context and the size to
read is negative, but i don't understand why.

Someone can help me find out what happens ?


mail-arrived
Description: Binary data


maillog
Description: Binary data


mail-receive
Description: Binary data


[Dovecot] plugin Again

2010-03-03 Thread Alex Baule
Hello

Someone know ho work the istream-concat ?

I made a copy of istream-concat, and use to manipulate my encrypted body.

But i got some questions about the stream->pos, stream->skip and position of
the message and pointer to buffer.

My messages have the W= with the email size decrypted, and it is a little
lass that the email size crypto.

For exemple:

I have a email with 6000k in crypto and decrypto the size is 5985 k:

The buffer from istream-concat is 4096, i read 4096 from get_stream_data,
but the result of this read is minor , lets say 4080, but the next read must
be from 4096. The "send to client" must be 4080, to send the correctly data
decrypted.

My Question is, what the variable used in istream-concat, to send the data
to client ? I need to update the stream->pos with my data length ??

I dont know if i made understand my question.


[Dovecot] Little Help with Plugin

2010-02-26 Thread Alex Baule
Hi everyone.


I Build a plugin to concat my body and header splited

Its have 2 "versions".

One is with the body without modifications.

The second, is with the body with crypto, and this crypto increase a little
the size of email.

So, without crypto, works fine, but with crypto i got stuck in some
modifications.

Because the email is splited, to handle it, i made a copy from
istream-concat.c, and in i_stream_concat_read  i made this changes.

Every place that have the i_stream_get_data i get the index from concat (if
is the frist or second stream) and if is the second, (my body) the unsigned
char *data is the return from my function.

if(cstream->cur_idx == 1){
data = decrypt_data(cstream->cur_input, &data_size);
}else{
data = i_stream_get_data(cstream->cur_input, &data_size);
}


In this part, i get the function i_stream_get_data and put in the function
too, to get the data in the same way, but i dont return the (_stream->buffer
+ _stream->skip;), i put this in a unsigned char * too, and work with this
variable.

The size_r, with the _stream->pos - _stream->skip, i update it, with the new
value get from my total length from the decrypted buffer.

In resume, every (inside istream_concat_read and istream_concat_read_next )

i_stream_get_data(cstream->cur_input, &data_size); // (in
istream_concat_read is "pos" variable)


I change to

if(cstream->cur_idx == 1){
data = decrypt_data(cstream->cur_input, &data_size); //(in
istream_concat_read is "pos" variable)
}else{
data = i_stream_get_data(cstream->cur_input, &data_size); //(in
istream_concat_read is "pos" variable)
}


Setting the unsigned char *data,  with my decrypted data and the pos or
data_size, with the length of buffer data , decrypted.

I Think there is Ok with this, and must be work, but i got some errors with
this, when the Email is read to get them, the total length read is diferent
from the W flag in header name.

FETCH [] for mailbox INBOX UID 2 got too little data: 1351 vs 1352
FETCH [] for mailbox INBOX UID 1 got too little data: 1357 vs 1360
FETCH [] for mailbox INBOX UID 3 got too little data: 691 vs 1303


There is some variable or something that i forgot to update with this news
values ? I use the Zlib plugin for exemple to do this.


Tks Guys !!!


[Dovecot] Get some headers Variables

2010-02-10 Thread Alex Baule
Hello Everyone again !!

I'm putting more functions in my plugin, and would need to access a value of
one variable that is going to put in the header, how can I get this value by
dovecot?

example, I have the header:
X-ThereisMy: yes

How can I get this value inside a plugin ?

There is something like  getHeaderVar("X-ThereisMy") ?


[Dovecot] Get plugins configuration

2010-02-09 Thread Alex Baule
Hello everyone


There is a way to get configurations in dovecot.conf inside a plugin ?


Re: [Dovecot] Create New Plugin

2010-02-04 Thread Alex Baule
Hi Timo

Tks, very much for the help... finally i finish my plugin and Its Work now.

Now i will start the second phase about this modifications.

I Need 3 more modifications one is encrypt my splited body (the header
will still open)... but i have some doubt.

The body email is splited in "boundarys", and i think that is better to
encrypt only the content of each  boundary, because is more easy to deal
with seek, stat and anothers funcions, i can use the default seek, because
its used to this, find every part of email...right ?.. Well if its right,
there is some hook to deal only with the body response ? Or its better
encrypt the entire body, and rewrite all functions ?

The Second is more simple, i need to create some defaults folders, like
"WHITE-LIST / BLACK-LIST" and  "QUARENTINE / SPAM" and the user will move
messages from the INBOX to this folders, but when the user move some message
from "QUARENTINE" to WHITE-LIST, the message will moved to INBOX and the
email address from the message will be put into white-list in postgres.
There is some hook to do this ?!

And the last one is more aasy  lol.

How i can put into conf.d or dovecot.conf, a configuration and read from my
plugin to use with the plugin.

Exemple: the folder that have my bodys, write this in configuration and get
from configuration in dovecot.conf.


Tks Again !!




2010/2/3 Timo Sirainen 

> On 4.2.2010, at 2.23, Alex Baule wrote:
>
> There is a date to the Dovecot 2.0 out as a official release ?
>
>
> "When it's stable."
>
> I use the 2.0 version to make a my plugin.
>
>
> That actually makes it easier then if you use configure
> --enable-header-install. Then you'll get dovecot-config file that you can
> use to find out what compiler flags you need.
>
> Actually that reminds me dovecot-config should probably be converted to
> become a pkg-config file to make it even easier..
>
>


Re: [Dovecot] Create New Plugin

2010-02-03 Thread Alex Baule
Ok...There is a good example to do explicit, it's better because can be
compiled separately from dovecot.

Tks !!

There is a date to the Dovecot 2.0 out as a official release ?

I use the 2.0 version to make a my plugin.



2010/2/3 Timo Sirainen 

> On 3.2.2010, at 14.41, Alex Baule wrote:
>
> > i have a Little question
> >
> > I dont know to much the autoconf/automake...there is a command or
> something
> > to do, to include my plugin in the Makefile for dovecot compile them when
> i
> > compile the hole package ??
> >
> > or i shoud go to the configure and makefile.am and put by hand ?
> >
> > I put my plugin in the plugins directory source tree.
>
> Well .. You could put them by hand and run autogen.sh and configure again.
> Or you could do the same as how other external plugins do it, with an
> explicit gcc line just giving all the necessary include paths etc. For
> example see: http://dovecot.org/patches/1.2/penalty.c
>
>


[Dovecot] Create New Plugin

2010-02-03 Thread Alex Baule
i have a Little question

I dont know to much the autoconf/automake...there is a command or something
to do, to include my plugin in the Makefile for dovecot compile them when i
compile the hole package ??

or i shoud go to the configure and makefile.am and put by hand ?

I put my plugin in the plugins directory source tree.


Re: [Dovecot] Plugin

2010-01-27 Thread Alex Baule
Hi Timo

Making my tests with the body and head separately (splited in 2 files and
concatenated with the i_stream_create_concat), getting some errors that I do
not understand.
I did not create the plugin, the changes is in maildir-mail.c. Is the same
that I write in the beginning of the email.
The error happens when there is attachment in the message, with a attachment
with 12K of size, i got the errors...
I got these messages from /var/log/mail


Jan 27 09:52:21 brc dovecot: IMAP(a...@exemplo.com.br): Panic: file
istream.c: line 96 (i_stream_read): assertion failed: (stream->eof)
Jan 27 09:52:21 brc dovecot: IMAP(a...@exemplo.com.br): Raw backtrace: imap
[0x80eb910] -> imap [0x80eb96a] -> imap [0x80eb21a] ->
imap(i_stream_read+0x14b) [0x80f0b0b] -> imap(i_stream_read_data+0x1d)
[0x80f0b8d] -> imap [0x80e3c5f] -> imap [0x80e4dfe] ->
imap(message_parser_parse_next_block+0x2a) [0x80e3daa] ->
imap(message_parser_parse_body+0x2c) [0x80e3f0c] -> imap [0x809e68e] -> imap
[0x809e7cf] -> imap(index_mail_get_special+0x3f9) [0x809ecf9] -> imap
[0x8088b07] -> imap [0x80666a5] -> imap(imap_fetch_more+0x104) [0x8067304]
-> imap(cmd_fetch+0x282) [0x805f012] -> imap(cmd_uid+0x7f) [0x806377f] ->
imap [0x80643dc] -> imap [0x806448b] -> imap(client_handle_input+0x3f)
[0x80645df] -> imap(client_input+0x5f) [0x806514f] ->
imap(io_loop_handler_run+0x110) [0x80f4620] -> imap(io_loop_run+0x28)
[0x80f36e8] -> imap(main+0x738) [0x806d628] ->
/lib/libc.so.6(__libc_start_main+0xd8) [0xb75d47c8] -> imap [0x805d071]
Jan 27 09:52:21 brc dovecot: dovecot: child 24407 (imap) killed with signal
6 (core dumps disabled)


Why this happens ? The size of message dont change, it is only splited.


2010/1/20 Timo Sirainen 

> On 20.1.2010, at 20.45, Alex Baule wrote:
>
> > Timo Sirainen send to me this modification, in
> > src/lib-storage/index/maildir/maildir-mail.c
> >
> > struct istream *full_input[3];
> > full_input[0] = i_stream_create_fd(fd, 0, TRUE);
> > full_input[1] = i_stream_create_fd(fd1, 0, TRUE);
> > full_input[2] = NULL;
> > input = i_stream_create_concat(full_
> > input);
> >
> > This is necessary because my Header and Body is splited.
> > This modification works fine.
> >
> > My question is:
> >
> > There is a way to do this with a plugin ?
> > I dont know how to implement this in a plugin, because i dont know what
> is
> > the hook to change the maildir_open_mail functions. (this is the function
> > with the modification above) .
>
> It's similar to how zlib plugin does its work. You need to copy&paste
> enough code from it, so that you'll get to
>
> static int zlib_maildir_get_stream(struct mail *_mail,
>
> The important part of the code below it that replaces the maildir's istream
> is:
>
>imail->data.destroying_stream = TRUE;
>i_stream_unref(&imail->data.stream);
>i_assert(!imail->data.destroying_stream);
>
>if (fd == -1)
>return -1;
>imail->data.stream = handler->create_istream(fd);
>
> So instead of handler->create_istream(fd), you'll use your own. Or actually
> IIRC you didn't even want to destroy the original stream, so instead of any
> of the above, you'd probably do something like:
>
> old_stream = imail->data.stream;
> imail->data.stream = create_your_stream(old_stream);
> i_stream_unref(&old_stream);
>
> > Another question is: There is a seek function, in dovecot, and in zlib
> > plugin, it is rewrite by another function, that use the "gzseek" to do
> the
> > seek. My splited body will be encrypted, and the crypto no have seek,
> > because the message will be encrypted. (if i open the message, decrypt
> and
> > seek to some position, maybe work).
> >
> > The seek function is really necessary to IMAP and maildir ?
>
> Well, gzseek() doesn't work any easier. It can't directly jump to wanted
> position. When seeking forwards, it'll just read and uncompress data until
> it reaches the wanted offset. When seeking backwards, it'll go back to
> beginning and start reading and uncompressing from there. That's why there's
> the "marked" code in istream-zlib that tries to
> avoid the backwards seeks. You could maybe use something like that too, but
> you could also put the whole thing through i_stream_create_seekable() and
> Dovecot just keeps the whole message in memory (by setting
> max_buffer_size=(size_t)-1).


[Dovecot] Plugin

2010-01-20 Thread Alex Baule
Hello Everyone...

Some time ago, i send some questions about plugins and concat 2 file
handles.

So, there is another questions about this.

Timo Sirainen send to me this modification, in
src/lib-storage/index/maildir/maildir-mail.c

struct istream *full_input[3];
full_input[0] = i_stream_create_fd(fd, 0, TRUE);
full_input[1] = i_stream_create_fd(fd1, 0, TRUE);
full_input[2] = NULL;
input = i_stream_create_concat(full_
input);

This is necessary because my Header and Body is splited.
This modification works fine.

My question is:

There is a way to do this with a plugin ?
I dont know how to implement this in a plugin, because i dont know what is
the hook to change the maildir_open_mail functions. (this is the function
with the modification above) .

Another question is: There is a seek function, in dovecot, and in zlib
plugin, it is rewrite by another function, that use the "gzseek" to do the
seek. My splited body will be encrypted, and the crypto no have seek,
because the message will be encrypted. (if i open the message, decrypt and
seek to some position, maybe work).

The seek function is really necessary to IMAP and maildir ?


[Dovecot] Plugins

2009-12-14 Thread Alex Baule
Hello everyone again.

i try to do a plugin... and i see there is a lot of "hook_*" calls in
various places

There is some documentation about this hooks ?

like:

hook_mail_storage_created = is calling when the email is

and go on


Tks.


Re: [Dovecot] Developer Documentation

2009-12-11 Thread Alex Baule
Wow

i am stupid ehehehehehe

concat the input, not the filedescriptor.

Tks again... Now its working !



2009/12/10 Timo Sirainen 

> On Thu, 2009-12-10 at 18:10 -0200, Alex Baule wrote:
> > do_open(mbox, "/storage/emexis/
> > exemplo.com.br/messages/alex/Maildir/body_test", &fd1);
> > fdp[0] = fd;
> > fdp[1] = fd1;
> >
> > input = i_stream_create_fd(fd, 0, TRUE);
> > input = i_stream_create_fd(fd1, 0, TRUE);
> > input = i_stream_create_concat(fdp);
>
> struct istream *full_input[3];
> full_input[0] = i_stream_create_fd(fd, 0, TRUE);
> full_input[1] = i_stream_create_fd(fd1, 0, TRUE);
> full_input[2] = NULL;
> input = i_stream_create_concat(full_input);
>
>


Re: [Dovecot] Developer Documentation

2009-12-10 Thread Alex Baule
Hi Timo

For tests i do it:

In src/lib-storage/index/maildir/maildir-mail.c


In the final of function maildir_open_mail i change the i_stream_create_fd
to this:

--- origin --
int fd  = -1;
.
.
.
.
.

if (fd == -1) {
*deleted_r = TRUE;
return NULL;
}

input = i_stream_create_fd(fd, 0, TRUE);
index_mail_set_read_buffer_size(mail, input);
return input;

--

 my  
int fd  = -1;
int fd1 = -1;
int fdp[2];
.
.
.
.
.
.
if (fd == -1) {
*deleted_r = TRUE;
return NULL;
}

do_open(mbox, "/storage/emexis/
exemplo.com.br/messages/alex/Maildir/body_test", &fd1);
fdp[0] = fd;
fdp[1] = fd1;

input = i_stream_create_concat(fdp);

index_mail_set_read_buffer_size(mail, input);
return input;
--
But the concat don't work.

I Try too create 2 streams and put this 2 fds in concat, not work too

-- my second 
int fd  = -1;
int fd1 = -1;
int fdp[2];
.
.
.
.
.
.
if (fd == -1) {
*deleted_r = TRUE;
return NULL;
}

do_open(mbox, "/storage/emexis/
exemplo.com.br/messages/alex/Maildir/body_test", &fd1);
fdp[0] = fd;
fdp[1] = fd1;

input = i_stream_create_fd(fd, 0, TRUE);
input = i_stream_create_fd(fd1, 0, TRUE);
input = i_stream_create_concat(fdp);





2009/12/10 Timo Sirainen 

> On Dec 10, 2009, at 11:16 AM, Alex Baule wrote:
>
> > Ok ... i understand...
> >
> > this is the last one...lol
> >
> > in zib plugin i see a implementation of i_stream_create_zlib, this is a
> "substitution" to the i_stream_create_fd , right ?
> >
> > So, i need to do every think like in istream-zlib.c (close, destroy,
> read, seek, stat and sync) to swap the original functions ?
>
> No, you don't need to implement a new istream, just ignore istream-zlib.c
> completely. Instead of the plugin calling i_stream_create_zlib, you just
> call i_stream_create_concat.
>
>


Re: [Dovecot] Developer Documentation

2009-12-10 Thread Alex Baule
Ok ... i understand...

this is the last one...lol

in zib plugin i see a implementation of i_stream_create_zlib, this is a
"substitution" to the i_stream_create_fd , right ?

So, i need to do every think like in istream-zlib.c (close, destroy, read,
seek, stat and sync) to swap the original functions ?

I try to do a way to save some space in disc, spliting the head and body in
2 filesbecause sometimes the users have the same email (Cc/CCb).

Doing this, i will use 1 body to various headers

In delivery by SMTP is easy, split in 2 and write the files... but in IMAP
is more complicated

Tks again !

2009/12/10 Timo Sirainen 

> On Dec 10, 2009, at 7:33 AM, Alex Baule wrote:
>
> > Hi Timo...
> >
> > There is a way to do this with a plugin ? or you pass the zlib-plugin for
> > reference ?
>
> You can do it with a plugin. I mention zlib plugin, because it works in a
> similar way by reading gzipped maildir files.
>
> > I can made this in the same monent the i_stream_create_fd()  open the
> email
> > in maildir,
> >
> > and make a extra i_stream_create_fd() to my file.. then put this 2
> streams
> > (email + myfile)
> >
> > in i_stream_create_concat()...
>
> Right.
>
>


Re: [Dovecot] Developer Documentation

2009-12-10 Thread Alex Baule
Hi Timo...

There is a way to do this with a plugin ? or you pass the zlib-plugin for
reference ?

I can made this in the same monent the i_stream_create_fd()  open the email
in maildir,

and make a extra i_stream_create_fd() to my file.. then put this 2 streams
(email + myfile)

in i_stream_create_concat()...

I will see the zlib-plugin code

tks

2009/12/9 Timo Sirainen 

> On Wed, 2009-12-09 at 23:30 -0200, Alex Baule wrote:
> > Let me explain to you
> >
> > i want to split the email in header and body...my smtp server do this
> > for me but, to read again in dovecot, i need to "point" the email
> > to this two files.
> >
> > This division in two parts is more like a test... and if the dovecot
> > can join again this two files in "read time" is good for me
>
> So you're thinking maybe you get better performance that way, or
> something? I was first thinking you'd want to add some automatic
> signature that gets modified once in a while, that wouldn't have worked.
>
> But yeah, you could do this with Maildir in a similar way than zlib
> plugin works. Instead of using i_stream_create_zlib(), you'd open the
> other file with i_stream_create_fd() and then make
> i_stream_create_concat() use both of the streams. Should be pretty easy
> to implement based on the zlib plugin code.
>
> Also when messages get expunged, you'd also need to delete the other
> file yourself. You can do that the same way as quota plugin decreases
> quota when message gets deleted.
>
> See http://wiki.dovecot.org/Design for more information about istreams
> and some other Dovecot code docs.
>


Re: [Dovecot] Developer Documentation

2009-12-09 Thread Alex Baule
Let me explain to you

i want to split the email in header and body...my smtp server do this for
me but, to read again in dovecot, i need to "point" the email to this
two files.

This division in two parts is more like a test... and if the dovecot can
join again this two files in "read time" is good for me

There is no much reason to do that ? yes... i know... but like i say, its
like a test to another thinks

There is a way to do this ?

2009/12/9 Timo Sirainen 

> On Tue, 2009-12-08 at 21:42 -0200, Alex Baule wrote:
> > I want to include lines from another file into every email when the user
> > request to read this email.
>
> Why do you want this? Why not add the extra contents on the SMTP server
> side when the mail is being delivered?
>
>


[Dovecot] Developer Documentation

2009-12-09 Thread Alex Baule
Hi Everyone

I Try to make a modification in dovecot Maildir system

I want to include lines from another file into every email when the user
request to read this email.

Is Like put some extras itens email. I try to find how to do this but what i
understand is, every email is read "on the fly", but i dont find exactly
where... i didnt find some "read" to do this.

Some one can help me to do this ?

Tks !