[Dovecot] vpopmail and open smtp relay

Timo Sirainen tss at iki.fi
Tue Jun 15 05:36:11 EEST 2004


On Mon, 2004-06-14 at 13:25, Chernomorets Sergey wrote:
> I'm using vpopmail's POP-before-SMTP auth, but dovecot don't support it, 
> so I'm wrote this patch

It's a bit easier in CVS since local/remote IPs are passed. Below is
what I committed. See the putenv() change, you most likely want to do
the same thing.

HAVE_VPOPMAIL_OPEN_SMTP_RELAY check should be added to configure I
think..

Index: passdb-vpopmail.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/passdb-vpopmail.c,v
retrieving revision 1.6
diff -u -r1.6 passdb-vpopmail.c
--- passdb-vpopmail.c	31 May 2004 18:57:25 -0000	1.6
+++ passdb-vpopmail.c	15 Jun 2004 02:42:57 -0000
@@ -14,6 +14,8 @@
 
 #include "userdb-vpopmail.h"
 
+#include <stdlib.h>
+
 static void
 vpopmail_verify_plain(struct auth_request *request, const char *password,
 		      verify_plain_callback_t *callback)
@@ -55,6 +57,25 @@
 		return;
 	}
 
+#ifdef HAVE_VPOPMAIL_OPEN_SMTP_RELAY
+	if (strcmp(request->protocol, "POP3") == 0 ||
+	    strcmp(request->protocol, "IMAP") == 0) {
+		const char *host = net_ip2addr(&request->remote_ip);
+		if (host != NULL) {
+			/* use putenv() directly rather than env_put() which
+			   would leak memory every time we got here. use a
+			   static buffer for putenv() as SUSv2 requirements
+			   would otherwise corrupt our environment later. */
+			static char ip_env[256];
+
+			i_snprintf(ip_env, sizeof(ip_env),
+				   "TCPREMOTEIP=%s", host);
+			putenv(ip_env);
+			open_smtp_relay();
+		}
+	}
+#endif
+
 	callback(PASSDB_RESULT_OK, request);
 }
 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://dovecot.org/pipermail/dovecot/attachments/20040615/4c0f631a/attachment-0001.bin>


More information about the dovecot mailing list