]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added support for vpopmail pop-before-smtp relay
authorTimo Sirainen <tss@iki.fi>
Tue, 15 Jun 2004 02:44:05 +0000 (05:44 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 15 Jun 2004 02:44:05 +0000 (05:44 +0300)
--HG--
branch : HEAD

src/auth/passdb-vpopmail.c

index 1cf77eb5588fe19055b8a32b4687c138953ec0a5..28d52279f10c2976788c7f481e92df51117695e4 100644 (file)
@@ -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 @@ vpopmail_verify_plain(struct auth_request *request, const char *password,
                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);
 }