Mihai Badici - 2012-10-08

I've used Dovecot for years as the IMAP server in a openldap-centric mail system configuration.
When I started looking for a solution to add Contacts/Calendar support i found Kolab who is, in my opinion, the right way to do it, because it only requires a few adds in the IMAP protocol at the server side ( which allow one to enjoy the stability of the solid linux mail servers family) and shift the burden on the client side, where is easy to add plugins, modify and test product etc.

So I embraced the idea, but also I want to keep my previous work and not to learn to configure a new IMAP server
( there is nothing wrong with learning, but I prefer to learn something else). Kolab Project use Cyrus, but since there is a metadata patch for dovecot, I choose the latter.
The IMAP metadata format is described in RFC 5464.

Packages

There are metadata patches for 2.0.x and 1.1.x branches. Since I had no problems with 2.0, I choose this one, because is newest.
As a matter of facts I tried to compile also 2.1.x branch, but it gave me some errors and I abandoned for the moment; I think it is not difficult to adapt the patch but I never had time to return to this.

So i used dovecot 2.0.21 ( during the time I compiled few previous versions without problems.)
You can download it from www.dovecot.org.
Update: The metadata plugin has a preprocesor directive named DOVECOT_PREREQ(2.1) who on my system is incorectly interpreted . I simply delete the if/else clause ( keeping the "true" branch ) and the plugin compiled without issues. So I upgraded to dovecot 2.1.10.

Because kolab is ldap-centric, you also need openldap libraries to compile.
My slackware 13.37 has openldap version 2.4.23 but I compiled against different versions, so use your distribution package .

I used the metadata patch from http://hg.dovecot.org/dovecot-metadata-plugin
Update: After my previous post, I encountered a bug in metadata plugin who prevents the storage of certain strings. In order to correct them, Dennis Schridde issued version 11 of the plugin, so use this version.

You also need gcc, m4 and I think autoconf/automake to compile the package.

Compile

First I built dovecot:
configure --with-ldap --sysconfdir=/etc --prefix=/usr

make; make install;

In fact I use slackbuild to build a package , but that's the ideea.

Once you do this you have a dovecot ( without metadata support) up and running.
I do it that way because dovecot libraries are needed to compile the patch.

So, after that you can extract the plugin and run ./configure --with-dovecot=/usr/lib/dovecot and then "make"

If you want to build on your current server, you can also run "make install".

I want to make a package, so I copied the resulting .so libs from src/.libs together with original dovecot files in a directory and use mkpkg.
It depends on your distribution.( there is also a conf file needed for the package, as follows) so don't run mkpkg yet.
The resulting package for Slackware is here: dovecot-with-metadata

Configure

In dovecot 2.x the configuration model was changed. Now we have multiple configuration files in a conf.d directory.

I will remember the relevant part.

In dovecot.conf I have:
metadata = file:/var/lib/dovecot/shared-metadata. This is the folder where you find all annotation. I think you can use %u if you want to store metadata in user's folders.

In 10-auth.conf I have:
!include auth-ldap.conf.ext

which include the ldap stuff usefull for directory access.

I have in auth-ldap.conf.ext:

passdb {
driver = ldap

# Path for LDAP configuration file, see example-config/dovecot-ldap.conf.ext
args = /etc/dovecot/dovecot-ldap.conf.ext
}

userdb {
driver = ldap
args = /etc/dovecot/dovecot-ldap.conf.ext

}

and in /etc/dovecot/dovecot-ldap.conf.ext:
hosts = localhost
base = dc=machinet
pass_attrs = uid=user,userPassword=password
user_filter = (uid=%u)
pass_filter = (uid=%u)

You can write better filters. The Kolab schema is different, I will try it someday.

In 10-master.conf are the metadata relevant section:

service dict {
# If dict proxy is used, mail processes should have access to its socket.
# For example: mode=0660, group=vmail and global mail_access_groups=vmail
unix_listener dict {
#mode = 0600
#user =
#group =
}

This will open a pipe named dict in /var/run/dovecot/
I had some troubles regarding the permissions to this pipe: since I use 10000 as uid and gid for my users, and I don't have such a user in /etc/passwd,
I cannot enter here user=10000 and group=10000, because dovecot return an error. I simply put a chown 10000.10000 /var/run/dovecot/dict in the initialization script;
there are better ways for sure to do it ( use an "real" account" ) but I didn't bother.

Bugs

I have few servers with this setup since one year ago and
there are no crashes ( which was my main concern till now). The metadata plugin is not in production use; however I syncronize my Android via kolab-droid with one of the servers.

Thanks
Well, there are many people I must thanks:

-people at kolab projects, starting with Torsten Grote who "force" me to write this
-Bernhard Herzog and Dennis Schridde who wrote the metadata plugin
- authors and contributors of Dovecot
and so many others

 

Last edit: Mihai Badici 2012-10-19