[dovecot-cvs] dovecot/src/auth auth-client-interface.h, 1.5, 1.6 mech.c, 1.23, 1.24 mech.h, 1.16, 1.17

cras at procontrol.fi cras at procontrol.fi
Mon May 31 21:04:49 EEST 2004


Update of /home/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv4696/src/auth

Modified Files:
	auth-client-interface.h mech.c mech.h 
Log Message:
Added %l, %r and %P variables and mail_log_prefix setting.



Index: auth-client-interface.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/auth-client-interface.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- a/auth-client-interface.h	29 May 2004 21:40:30 -0000	1.5
+++ b/auth-client-interface.h	31 May 2004 18:04:46 -0000	1.6
@@ -50,6 +50,8 @@
 
 	enum auth_client_request_new_flags flags;
 
+	uint32_t ip_family; /* if non-zero, data begins with local/remote IPs */
+
 	uint32_t protocol_idx;
 	uint32_t mech_idx;
 	uint32_t initial_resp_idx;

Index: mech.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- a/mech.c	30 May 2004 01:40:30 -0000	1.23
+++ b/mech.c	31 May 2004 18:04:46 -0000	1.24
@@ -77,9 +77,17 @@
 {
         struct mech_module *mech;
 	struct auth_request *auth_request;
+	size_t ip_size = 1;
+
+	if (request->ip_family == AF_INET)
+		ip_size = 4;
+	else if (request->ip_family != 0)
+		ip_size = sizeof(auth_request->local_ip.ip);
+	else
+		ip_size = 0;
 
 	/* make sure data is NUL-terminated */
-	if (request->data_size == 0 || request->initial_resp_idx == 0 ||
+	if (request->data_size <= ip_size*2 || request->initial_resp_idx == 0 ||
 	    request->mech_idx >= request->data_size ||
 	    request->protocol_idx >= request->data_size ||
 	    request->initial_resp_idx > request->data_size ||
@@ -127,6 +135,16 @@
 			p_strdup(auth_request->pool,
 				 (const char *)data + request->protocol_idx);
 
+		if (request->ip_family != 0) {
+			auth_request->local_ip.family = request->ip_family;
+			auth_request->remote_ip.family = request->ip_family;
+				
+
+			memcpy(&auth_request->local_ip, data, ip_size);
+			memcpy(&auth_request->remote_ip, data + ip_size,
+			       ip_size);
+		}
+
 		hash_insert(conn->auth_requests, POINTER_CAST(request->id),
 			    auth_request);
 
@@ -265,6 +283,10 @@
 		{ 'n', NULL },
 		{ 'd', NULL },
 		{ 'p', NULL },
+		{ 'h', NULL },
+		{ 'l', NULL },
+		{ 'r', NULL },
+		{ 'P', NULL },
 		{ '\0', NULL }
 	};
 	struct var_expand_table *tab;
@@ -281,6 +303,12 @@
 	if (tab[2].value != NULL)
 		tab[2].value = escape_func(tab[2].value+1);
 	tab[3].value = auth_request->protocol;
+	/* tab[4] = we have no home dir */
+	if (auth_request->local_ip.family != 0)
+		tab[5].value = net_ip2addr(&auth_request->local_ip);
+	if (auth_request->remote_ip.family != 0)
+		tab[6].value = net_ip2addr(&auth_request->remote_ip);
+	tab[7].value = dec2str(auth_request->conn->pid);
 	return tab;
 }
 

Index: mech.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- a/mech.h	29 May 2004 21:40:30 -0000	1.16
+++ b/mech.h	31 May 2004 18:04:46 -0000	1.17
@@ -1,6 +1,7 @@
 #ifndef __MECH_H
 #define __MECH_H
 
+#include "network.h"
 #include "auth-client-interface.h"
 
 struct auth_client_connection;
@@ -20,6 +21,7 @@
 	time_t created;
 
 	char *protocol;
+	struct ip_addr local_ip, remote_ip;
 	mech_callback_t *callback;
 
 	int (*auth_initial)(struct auth_request *auth_request,



More information about the dovecot-cvs mailing list