[dovecot] tcpserver/mailfront/stunnel with patch (was Re: inetd/xinetd/tcpserver support)

Charlie Brady charlieb-dovecot at e-smith.com
Fri Mar 21 00:20:51 EET 2003


On 20 Mar 2003, Timo Sirainen wrote:

> On Thu, 2003-03-20 at 03:30, Charlie Brady wrote:
> > I have a working tcpserver system, but one using a substantially different 
> > process mix. I haven't used imap-login at all, but have used 
> > imapfront-auth from Bruce Guenter's mailfront package 
> > (http://www.untroubled.org/mailfront/).
> > 
> > 002 login foo xxxxx
> > * PREAUTH [CAPABILITY IMAP4rev1 SORT THREAD=REFERENCES MULTIAPPEND 
> > UNSELECT LITERAL+ IDLE CHILDREN LISTEXT LIST-SUBSCRIBED] Logged in as foo
> 
> There's one problem. Dovecot shouldn't reply with PREAUTH but "002 OK".
> Mailfront gives the 002 in environment variable, so you'd have to modify
> Dovecot to use it.

Done - patch is attached.

Here is the run file for running stunnel/mailfront/dovecot under 
tcpserver:

#!/bin/sh

concurrency=20
ulimitdata=3000000
CVM_SASL_PLAIN=cvm-local:/tmp/.cvm-unix-local
export CVM_SASL_PLAIN
CVM_ACCOUNT_SPLIT_CHARS=
export CVM_ACCOUNT_SPLIT_CHARS

SSLUID=`id -u stunnel`
SSLGID=`id -g stunnel`

exec 2>&1
exec \
  softlimit -m $ulimitdata \
  tcpserver -dHRvX \
  -c "$concurrency" \
  -x tcp.cdb \
  0 imap \
   makesock \
   stunnel -D debug -/ ssl -s "$SSLUID" -g "$SSLGID" \
       -N imap \
       -i -R seed -p imapd.pem -n imap- -f -F 3 \
    -makesock_connect_to \
  /usr/bin/imapfront-auth \
  /usr/libexec/dovecot/imap

This is the chroot jail required by stunnel:

-rw-r-----    1 root     stunnel ... ssl/imapd.pem
-rw-------    1 stunnel  stunnel ... ssl/seed
-rw-r--r--    1 root     root    ... ssl/usr/share/ssl/openssl.cnf

--
Charlie

-------------- next part --------------
--- src/imap/main.c.orig	Thu Mar 20 16:32:48 2003
+++ src/imap/main.c	Thu Mar 20 17:00:37 2003
@@ -70,6 +70,7 @@
 	struct client *client;
 	struct mail_storage *storage;
 	const char *user, *mail, *str;
+	const char *tag;
 	int hin, hout;
 
 	lib_init_signals(sig_quit);
@@ -124,11 +125,16 @@
 
 	client = client_create(hin, hout, storage);
 
-	if (IS_STANDALONE()) {
+	tag = getenv("IMAPLOGINTAG");
+	if (tag == NULL || *tag == '\0') {
 		client_send_line(client, t_strconcat(
 			"* PREAUTH [CAPABILITY "CAPABILITY_STRING"] "
 			"Logged in as ", user, NULL));
-	}
+	} else {
+		    client_send_line(client,
+		    t_strconcat(tag, " OK Logged in.", NULL));
+	 	}
+
 }
 
 static void main_deinit(void)


More information about the dovecot mailing list