mailfront imapfront-auth with dovecot 1.2.16 : SUCCESS

Giam Teck Choon <[email protected]> Wed, 10 Nov 2010 09:20:58 +0800
Newsgroups gmane.comp.sysutils.bgware
Organization CHOON.NET
Message-ID <[email protected]>
Hi,

This is just to share with the list members that upon couple hours of 
researching, I have successfully run mailfront v1.17 imapfront-auth with 
dovecot v1.2.16 which doesn't require dovecot service to be running.

I know http://mij.oltrelinux.com/net/dovecot-qmail-vmailmgr/ and that 
requires dovecot service running and I can't use with imapfront-auth.  I 
prefer to use mailfront + cvm (pop3d/pop3sd with pop3front-auth and 
imapd/imapsd with imapfront-auth) so that all related mail services are 
running under daemontools + ucspi-tcp.

Below is the wrapper /usr/bin/mailfront-imapfront-auth-dovecot or name 
whatever you like and chmod +x /usr/bin/mailfront-imapfront-auth-dovecot:
--------------------8<----------8<----------8<----------8<---------------------
#!/bin/sh

if [ -n "$MAIL" ] ; then
	export MAIL=maildir:`echo $MAIL | sed 's@:@::@g'`
fi
exec "$@"
--------------------8<----------8<----------8<----------8<---------------------

Below is example imapd/run file which works for courier-imap and dovecot:
--------------------8<----------8<----------8<----------8<---------------------
#!/bin/sh

DOVECOTWRAPPER=""
# Default to support dovecot 1.0.x
if [ -x "/usr/libexec/dovecot/imap" ] ; then
	IMAPD=/usr/libexec/dovecot/imap
	if [ -x "/usr/bin/mailfront-imapfront-auth-dovecot" ] ; then
		DOVECOTWRAPPER=/usr/bin/mailfront-imapfront-auth-dovecot
	elif [ -x "/usr/local/bin/mailfront-imapfront-auth-dovecot" ] ; then
		DOVECOTWRAPPER=/usr/local/bin/mailfront-imapfront-auth-dovecot
	fi
elif [ -x "/usr/local/bin/imapd" ] ; then
	IMAPD=/usr/local/bin/imapd
elif [ -x "/usr/lib/courier-imap/bin/imapd" ] ; then
	IMAPD=/usr/lib/courier-imap/bin/imapd
else
	IMAPD=/usr/bin/imapd
fi

if [ -x "/usr/bin/imapfront-auth" ] ; then
	IMAPFRONT_AUTH=/usr/bin/imapfront-auth
else
	IMAPFRONT_AUTH=/usr/local/bin/imapfront-auth
fi

ulimitdata=500000000
concurrency=40

CVM_SASL_PLAIN=cvm-local:/tmp/.cvm-vmailmgr
CVM_SASL_LOGIN=cvm-local:/tmp/.cvm-vmailmgr
export CVM_SASL_PLAIN
export CVM_SASL_LOGIN

exec \
softlimit -m $ulimitdata \
tcpserver -DHRUvX -c "$concurrency" -l "`head -n 1 /var/qmail/control/me`" \
	-x /etc/tcpcontrol/imap.cdb 0 imap \
$IMAPFRONT_AUTH $DOVECOTWRAPPER \
$IMAPD 2>&1
--------------------8<----------8<----------8<----------8<---------------------

C wrapper source can be found at:

http://choon.net/mailfront-imapfront-auth-dovecot.php

Many thanks to MIJ at http://mij.oltrelinux.com as I copied one of his 
source code function.  Sorry, I am not good in C at all and only code in 
C occasionally.

Hope the above information is useful to someone ;)

Thanks.

Kindest regards,
Giam Teck Choon