[dovecot-cvs] dovecot/src/lib-auth auth-client.c, 1.4, 1.5 auth-client.h, 1.6, 1.7 auth-server-connection.c, 1.5, 1.6 auth-server-connection.h, 1.4, 1.5 auth-server-request.c, 1.11, 1.12

cras at procontrol.fi cras at procontrol.fi
Sat Jul 3 01:03:39 EEST 2004


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

Modified Files:
	auth-client.c auth-client.h auth-server-connection.c 
	auth-server-connection.h auth-server-request.c 
Log Message:
Added APOP authentication for POP3. Patch by Andrey Panin.

This required some changes in auth APIs.



Index: auth-client.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-auth/auth-client.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- auth-client.c	30 May 2004 01:40:47 -0000	1.4
+++ auth-client.c	2 Jul 2004 22:03:37 -0000	1.5
@@ -87,6 +87,22 @@
 	return NULL;
 }
 
+int auth_client_reserve_connection(struct auth_client *client, const char *mech,
+				   struct auth_connect_id *id_r)
+{
+	struct auth_server_connection *conn;
+	const char *error;
+
+	conn = auth_server_connection_find_mech(client, mech, &error);
+	if (conn == NULL)
+		return FALSE;
+
+	id_r->server_pid = conn->server_pid;
+	id_r->connect_uid = conn->connect_uid;
+
+	return TRUE;
+}
+
 int auth_client_is_connected(struct auth_client *client)
 {
 	return !client->reconnect &&

Index: auth-client.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-auth/auth-client.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- auth-client.h	31 May 2004 18:04:47 -0000	1.6
+++ auth-client.h	2 Jul 2004 22:03:37 -0000	1.7
@@ -13,6 +13,11 @@
 	unsigned int advertise:1;
 };
 
+struct auth_connect_id {
+	unsigned int server_pid;
+	unsigned int connect_uid;
+};
+
 struct auth_request_info {
 	const char *mech;
 	const char *protocol;
@@ -46,10 +51,17 @@
 const struct auth_mech_desc *
 auth_client_find_mech(struct auth_client *client, const char *name);
 
+/* Reserve connection for specific mechanism. The id can be given to
+   auth_client_request_new() to force it to use the same connection, or fail.
+   This is currently useful only for APOP authentication. Returns TRUE if
+   successfull. */
+int auth_client_reserve_connection(struct auth_client *client, const char *mech,
+				   struct auth_connect_id *id_r);
+
 /* Create a new authentication request. callback is called whenever something
-   happens for the request. */
+   happens for the request. id can be NULL. */
 struct auth_request *
-auth_client_request_new(struct auth_client *client,
+auth_client_request_new(struct auth_client *client, struct auth_connect_id *id,
 			const struct auth_request_info *request_info,
 			auth_request_callback_t *callback, void *context,
 			const char **error_r);

Index: auth-server-connection.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-auth/auth-server-connection.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- auth-server-connection.c	30 May 2004 01:40:47 -0000	1.5
+++ auth-server-connection.c	2 Jul 2004 22:03:37 -0000	1.6
@@ -80,7 +80,8 @@
 			conn->has_plain_mech = TRUE;
 	}
 
-	conn->pid = handshake->server_pid;
+	conn->server_pid = handshake->server_pid;
+	conn->connect_uid = handshake->connect_uid;
 	conn->available_auth_mechs_count =
 		buffer_get_used_size(buf) / sizeof(mech_desc);
 	conn->available_auth_mechs = buffer_free_without_data(buf);

Index: auth-server-connection.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-auth/auth-server-connection.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- auth-server-connection.h	30 May 2004 01:40:47 -0000	1.4
+++ auth-server-connection.h	2 Jul 2004 22:03:37 -0000	1.5
@@ -37,7 +37,9 @@
 	struct istream *input;
 	struct ostream *output;
 
-	unsigned int pid;
+	unsigned int server_pid;
+	unsigned int connect_uid;
+
 	const struct auth_mech_desc *available_auth_mechs;
 	unsigned int available_auth_mechs_count;
         struct auth_client_request_reply reply;

Index: auth-server-request.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-auth/auth-server-request.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- auth-server-request.c	31 May 2004 18:04:47 -0000	1.11
+++ auth-server-request.c	2 Jul 2004 22:03:37 -0000	1.12
@@ -247,7 +247,7 @@
 }
 
 struct auth_request *
-auth_client_request_new(struct auth_client *client,
+auth_client_request_new(struct auth_client *client, struct auth_connect_id *id,
 			const struct auth_request_info *request_info,
 			auth_request_callback_t *callback, void *context,
 			const char **error_r)
@@ -255,8 +255,20 @@
 	struct auth_server_connection *conn;
 	struct auth_request *request;
 
-	conn = auth_server_connection_find_mech(client, request_info->mech,
-						error_r);
+	if (id == NULL) {
+		conn = auth_server_connection_find_mech(client,
+							request_info->mech,
+							error_r);
+	} else {
+		*error_r = NULL;
+		conn = client->connections;
+		for (; conn != NULL; conn = conn->next) {
+			if (conn->connect_uid == id->connect_uid &&
+			    conn->server_pid == id->server_pid)
+				break;
+		}
+	}
+
 	if (conn == NULL)
 		return NULL;
 
@@ -324,5 +336,5 @@
 
 unsigned int auth_client_request_get_server_pid(struct auth_request *request)
 {
-	return request->conn->pid;
+	return request->conn->server_pid;
 }



More information about the dovecot-cvs mailing list