Discussion:
Need help to compile and install a minimal dovecot imap plugin
Stefan Arentz
2014-08-30 17:36:35 UTC
Permalink
I am trying to create a plugin that adds a new IMAP capability. So far I have this:



const char *foo_plugin_version = DOVECOT_ABI_VERSION;

static struct module *foo_module;
static imap_client_created_func_t *next_hook_client_created;

static void foo_client_created(struct client **client)
{
str_append((*client)->capability_string, " XFOO");

if (next_hook_client_created != NULL) {
next_hook_client_created(client);
}
}

void foo_plugin_init(struct module *module)
{
i_info(?init?);
foo_module = module;
next_hook_client_created = imap_client_created_hook_set(foo_client_created);
}

void foo_plugin_deinit(void)
{
i_info(?deinit?);
imap_client_created_hook_set(next_hook_client_created);
}

const char foo_plugin_binary_dependency[] = "imap?;



On Fedora 20, with the dovecot and dovecot-devel packages installed, I compile this with:

cc -Wall -shared -fPIC -DHAVE_CONFIG_H -I/usr/include/dovecot -o lib20_foo_plugin.so foo-plugin.c



And then install with:

sudo cp lib20_foo_plugin.so /usr/lib64/dovecot/

(I also have mail_plugin_dir = /usr/lib64/dovecot in 10-mail.conf)



I enable this plugin in /etc/dovecot/conf.d/20-imap.conf with:

protocol imap {
mail_plugins = $mail_plugins foo
}


But ? nothing happens. No warnings, no errors, no crashes.

How do I debug this? Am I missing something obvious?

Does the naming of the plugin matter?

S.
Stefan Arentz
2014-08-31 18:45:25 UTC
Permalink
Post by Stefan Arentz
I am trying to create a plugin that adds a new IMAP capability.
To get a much simpler example working, I?ve created a very simple ?empty? plugin to get the basics works.

https://github.com/st3fan/dovecot-empty-plugin <https://github.com/st3fan/dovecot-empty-plugin>

This compiles, but there is no way I can get it to actually load.

On Ubuntu 12.04.5 I have moved the empty_plugin.so to /usr/lib/dovecot/modules and I have added it to the dovecot configuration as follows:

protocol imap {
mail_plugins = $mail_plugins empty
}

In /etc/dovecot/conf.d/20-imap.conf

No results however.

Should it actually be possible to add a new plugin to an existing install of Dovecot? Or is the plugin list hardcoded or somehow fixed?

S.
Stefan Arentz
2014-08-31 19:11:41 UTC
Permalink
Post by Stefan Arentz
Post by Stefan Arentz
I am trying to create a plugin that adds a new IMAP capability.
To get a much simpler example working, I?ve created a very simple ?empty? plugin to get the basics works.
https://github.com/st3fan/dovecot-empty-plugin <https://github.com/st3fan/dovecot-empty-plugin>
This compiles, but there is no way I can get it to actually load.
I figured part of it out!

I was testing this plugin simply by doing a telnet localhost 143 and expecting the plugin to kick in right away.

But that is not happening. The plugin will not initialize until you issue a login command!

I now see my plugin being loaded and it is printing the debug messages in _init() and _deinit().

S.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://dovecot.org/pipermail/dovecot/attachments/20140831/44df3fb4/attachment.sig>
Loading...