Re: [Dovecot] How to write plugin

2007-11-20 Thread Eugene Prokopiev
I tried to use http://www.dovecot.org/patches/copy_plugin.c as simple
example. My code is attached. I see plugin loading in logs:

Nov 20 12:29:33 mail dovecot-auth: pam_tcb(dovecot:auth):
Authentication passed for enp from (uid=0)
Nov 20 12:29:33 mail dovecot: imap-login: Login: user=enp,
method=PLAIN, rip=192.168.46.23, lip=10.0.101.103
Nov 20 12:29:33 mail dovecot: IMAP(enp): copy plugin init
Nov 20 12:29:33 mail dovecot: IMAP(enp):

But I can't see nothing while message is copied :(

I tried to send mail to Fabio M. Catunda catunda at
contactnet.com.br yesterday, but I see no relpy. Fábio, can you show
me you code?
/*
   Example plugin to show how to hook into COPY command.

   gcc -fPIC -shared -Wall -I../lib -I../.. -I../lib-storage -I../lib-mail -I../lib-imap -DHAVE_CONFIG_H copy_plugin.c -o copy_plugin.so
*/

#include common.h
#include commands.h

static int cmd_copy_plugin(struct client *client)
{
  const char *messageset, *mailbox;

  i_info(copy plugin action init\n);

  /* message set mailbox */
  if (!client_read_string_args(client, 2, messageset, mailbox))
	return FALSE;

  if (!cmd_copy(client))
	return FALSE;

  i_info(copying done to %s\n, mailbox);
  return TRUE;
}

void copy_plugin_init(void)
{
  i_info(copy plugin init\n);
  command_unregister(COPY);
  /* i_strdup() here is a kludge to avoid crashing in commands_deinit()
 since modules are unloaded before it's called, this COPY string
 would otherwise point to nonexisting memory. */
command_register(i_strdup(COPY), cmd_copy_plugin);
}

void copy_plugin_deinit(void)
{
  i_info(copy plugin deinit\n);
}


[Dovecot] dspam integration

2007-11-19 Thread Eugene Prokopiev
Hi,

I see http://johannes.sipsolutions.net/Projects/dovecot-antispam and
http://blog.cynapses.org/2007/09/13/dovecot-dspam-plugin/ solutions.
Second git repo is not answer, first one is cloned, but I see some
drawbacks with it.

Dspam backend is more native solution but libdspam using instead of
dspam external binary looks like preffered way to integrate dspam.
Another problem is waiting for dspam child process exit, so IMAP
session is blocked. Why not to fork and forget dspam child process?

Email sender backend is non-blocking, but using MTA is great overhead.
Calling external program with some args and mail body via pipe can be
more suitable way, so external program may be dspam binary directly or
shell/perl/python filter to any antispam engine via sendmail or
something else.

Has anybody plans to implement this features or it will be better to
try it myself?


[Dovecot] How to write plugin

2007-11-19 Thread Eugene Prokopiev
Hi,

Where can I find documentation for plugin writers? Now I see
mail-log-plugin source, but I can't understand how entry points
(functions mail-log-plugin-init and mail-log-plugin-deinit) are
defined to execute some actions on load/unload/copy messages.

Can anybody comments this?