[Dovecot] vpopmail and open smtp relay

Chernomorets Sergey csa at cyberdude.ru
Mon Jun 14 13:25:41 EEST 2004


I'm using vpopmail's POP-before-SMTP auth, but dovecot don't support it, 
so I'm wrote this patch

==============================================================
diff -Naur dovecot-0.99.10.5/src/auth/auth-login-interface.h 
dovecot-0.99.10.5-patched/src/auth/auth-login-interface.h
--- dovecot-0.99.10.5/src/auth/auth-login-interface.h    Sun May 18 
16:26:28 2003
+++ dovecot-0.99.10.5-patched/src/auth/auth-login-interface.h    Mon Jun 
14 13:18:15 2004
@@ -1,6 +1,10 @@
 #ifndef __AUTH_LOGIN_INTERFACE_H
 #define __AUTH_LOGIN_INTERFACE_H
 
+#ifdef PASSDB_VPOPMAIL
+#include "network.h"
+#endif
+
 /* max. size for auth_login_request_continue.data[] */
 #define AUTH_LOGIN_MAX_REQUEST_DATA_SIZE 4096
 
@@ -50,6 +54,10 @@
 
     enum auth_mech mech;
     enum auth_protocol protocol;
+    
+#ifdef PASSDB_VPOPMAIL    
+    struct ip_addr client_ip;
+#endif
 };
 
 /* Continue authentication request */
diff -Naur dovecot-0.99.10.5/src/auth/mech.c 
dovecot-0.99.10.5-patched/src/auth/mech.c
--- dovecot-0.99.10.5/src/auth/mech.c    Sun May 18 16:26:28 2003
+++ dovecot-0.99.10.5-patched/src/auth/mech.c    Mon Jun 14 13:27:33 2004
@@ -98,7 +98,10 @@
         auth_request->conn = conn;
         auth_request->id = request->id;
         auth_request->protocol = request->protocol;
-
+#ifdef PASSDB_VPOPMAIL
+        auth_request->client_ip = request->client_ip;
+#endif
+        
         hash_insert(conn->auth_requests, POINTER_CAST(request->id),
                 auth_request);
     }
diff -Naur dovecot-0.99.10.5/src/auth/mech.h 
dovecot-0.99.10.5-patched/src/auth/mech.h
--- dovecot-0.99.10.5/src/auth/mech.h    Sun May 18 16:26:28 2003
+++ dovecot-0.99.10.5-patched/src/auth/mech.h    Mon Jun 14 13:26:29 2004
@@ -19,6 +19,10 @@
     enum auth_protocol protocol;
     mech_callback_t *callback;
 
+#ifdef PASSDB_VPOPMAIL    
+    struct ip_addr client_ip;
+#endif
+
     int (*auth_continue)(struct auth_request *auth_request,
                  struct auth_login_request_continue *request,
                  const unsigned char *data,
diff -Naur dovecot-0.99.10.5/src/auth/passdb-vpopmail.c 
dovecot-0.99.10.5-patched/src/auth/passdb-vpopmail.c
--- dovecot-0.99.10.5/src/auth/passdb-vpopmail.c    Thu Feb 20 03:46:51 2003
+++ dovecot-0.99.10.5-patched/src/auth/passdb-vpopmail.c    Mon Jun 14 
13:29:49 2004
@@ -14,6 +14,8 @@
 
 #include "userdb-vpopmail.h"
 
+#include "env-util.h"
+
 static void
 vpopmail_verify_plain(struct auth_request *request, const char *password,
               verify_plain_callback_t *callback)
@@ -21,6 +23,7 @@
     char vpop_user[VPOPMAIL_LIMIT], vpop_domain[VPOPMAIL_LIMIT];
     struct vqpasswd *vpw;
     int result;
+    const char *ip_addr_fe;
 
     vpw = vpopmail_lookup_vqp(request->user,
                   vpop_user, vpop_domain);
@@ -57,6 +60,15 @@
         return;
     }
 
+    /* it is needed for open smtp relay  */
+    
+    ip_addr_fe = net_ip2addr(&request->client_ip);
+    if (ip_addr_fe == NULL)
+        ip_addr_fe = "??";
+    
+    env_put(t_strconcat("TCPREMOTEIP=", ip_addr_fe, NULL));
+    open_smtp_relay();
+    
     callback(PASSDB_RESULT_OK, request);
 }
 
diff -Naur dovecot-0.99.10.5/src/login-common/auth-connection.c 
dovecot-0.99.10.5-patched/src/login-common/auth-connection.c
--- dovecot-0.99.10.5/src/login-common/auth-connection.c    Mon May 26 
19:27:13 2003
+++ dovecot-0.99.10.5-patched/src/login-common/auth-connection.c    Mon 
Jun 14 13:21:22 2004
@@ -298,6 +298,9 @@
     struct auth_connection *conn;
     struct auth_request *request;
     struct auth_login_request_new auth_request;
+#ifdef PASSDB_VPOPMAIL    
+    struct client *_client = context;
+#endif
 
     if (auth_reconnect)
         auth_connect_missing();
@@ -325,6 +328,9 @@
     auth_request.protocol = protocol;
     auth_request.mech = request->mech;
     auth_request.id = request->id;
+#ifdef PASSDB_VPOPMAIL
+    auth_request.client_ip = _client->ip;
+#endif
     if (o_stream_send(request->conn->output, &auth_request,
               sizeof(auth_request)) < 0) {
         errno = request->conn->output->stream_errno;


More information about the dovecot mailing list