How to fix the Gamin/FAM issue

On my docker mail server, I experienced the following problem connecting to my IMAP server:

# Telnet authentication
$ telnet 192.168.59.103 143
Trying 192.168.59.103...
Connected to 192.168.59.103.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2011 Double Precision, Inc.  See COPYING for distribution information.
a1 LOGIN user@domain.tld mypassword
* OK [ALERT] Filesystem notification initialization error -- contact your mail administrator (check for configuration errors with the FAM/Gamin library)
a1 OK LOGIN Ok.

As you can see, the authentication succeeded but a alert message appears.

As you can also see, the error is "client side". Nothing appears on my server logs.

I used libfam0 and fam daemon on an Ubuntu Trusty docker image.

Use gamin instead of fam

This is what is said about gamin on the Ubuntu website:

libgamin0
  Client library for the gamin file and directory monitoring system
or libfam0
  Client library to control the FAM daemon also a virtual package provided by libgamin0

I moved from fam to gamin:

apt-get install gamin

But the error moved from client side to server side.

imapd: Failed to connect to socket /tmp/fam-- 

I read a lot of posts over the Internet and many problems have been resolved installing gamin.

So I supposed that I had another problem.

So, especially if you are a docker user, read the next part.

Use a "real" unix user

In my postfix configuration, I forced the ownership of my mail data like this:

# Mail directory
virtual_mailbox_base = /var/mail
virtual_mailbox_domains = /etc/postfix/vhost
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000

The "problem" is that I did not have a unix user with uid 5000.

Without a real user, the gam_server daemon won't start.

I added a specific unix user with the appropriate uid and everything went OK, client and server side.

The short version, to summarize

If you experience one of these errors:

# Client Side, visible when trying to authenticate on the IMAP server using telnet
Filesystem notification initialization error -- contact your mail administrator (check for configuration errors with the FAM/Gamin library)

or

# Server Side, usually in /var/log/mail.log
imapd: Failed to connect to socket /tmp/fam--

Here is what you need to do:

  • Install gamin instead of fam,
  • Verify that your files are owned by an existing / real unix user, otherwise, gam_server won't start