[dovecot-cvs] dovecot/src/auth Makefile.am, 1.27, 1.28 auth-client-connection.c, 1.6, 1.7 auth-client-connection.h, 1.1, 1.2 auth-client-interface.h, 1.6, 1.7 auth-master-connection.c, 1.8, 1.9 mech.c, 1.26, 1.27

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


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

Modified Files:
	Makefile.am auth-client-connection.c auth-client-connection.h 
	auth-client-interface.h auth-master-connection.c mech.c 
Log Message:
Added APOP authentication for POP3. Patch by Andrey Panin.

This required some changes in auth APIs.



Index: Makefile.am
===================================================================
RCS file: /home/cvs/dovecot/src/auth/Makefile.am,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- Makefile.am	18 Jun 2004 03:40:12 -0000	1.27
+++ Makefile.am	2 Jul 2004 22:03:37 -0000	1.28
@@ -31,6 +31,7 @@
 	mech-plain.c \
 	mech-cram-md5.c \
 	mech-digest-md5.c \
+	mech-apop.c \
 	mycrypt.c \
 	passdb.c \
 	passdb-bsdauth.c \

Index: auth-client-connection.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/auth-client-connection.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- auth-client-connection.c	29 May 2004 21:40:30 -0000	1.6
+++ auth-client-connection.c	2 Jul 2004 22:03:37 -0000	1.7
@@ -185,7 +185,10 @@
 struct auth_client_connection *
 auth_client_connection_create(struct auth_master_connection *master, int fd)
 {
+	static unsigned int connect_uid_counter = 0;
 	struct auth_client_connection *conn;
+	struct auth_client_handshake_reply handshake_reply;
+
 	pool_t pool;
 
 	pool = pool_alloconly_create("Auth client", 4096);
@@ -193,6 +196,7 @@
 	conn->pool = pool;
 	conn->master = master;
 	conn->refcount = 1;
+	conn->connect_uid = ++connect_uid_counter;
 
 	conn->fd = fd;
 	conn->input = i_stream_create_file(fd, default_pool, MAX_INBUF_SIZE,
@@ -207,9 +211,13 @@
 	conn->next = master->clients;
 	master->clients = conn;
 
-	if (o_stream_send(conn->output, master->handshake_reply,
-			  sizeof(*master->handshake_reply) +
-			  master->handshake_reply->data_size) < 0) {
+	handshake_reply = *master->handshake_reply;
+	handshake_reply.connect_uid = conn->connect_uid;
+
+	if (o_stream_send(conn->output, &handshake_reply,
+			  sizeof(handshake_reply)) < 0 ||
+	    o_stream_send(conn->output, master->handshake_reply + 1,
+			  handshake_reply.data_size) < 0) {
 		auth_client_connection_destroy(conn);
 		conn = NULL;
 	}

Index: auth-client-connection.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/auth-client-connection.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- auth-client-connection.h	22 Aug 2003 02:42:13 -0000	1.1
+++ auth-client-connection.h	2 Jul 2004 22:03:37 -0000	1.2
@@ -18,6 +18,7 @@
 	struct hash_table *auth_requests;
 
 	unsigned int pid;
+	unsigned int connect_uid;
 };
 
 struct auth_client_connection *

Index: auth-client-interface.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/auth-client-interface.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- auth-client-interface.h	31 May 2004 18:04:46 -0000	1.6
+++ auth-client-interface.h	2 Jul 2004 22:03:37 -0000	1.7
@@ -37,6 +37,7 @@
 /* Server -> Client */
 struct auth_client_handshake_reply {
 	unsigned int server_pid; /* unique auth process identifier */
+	unsigned int connect_uid; /* unique connection identifier */
 
 	uint32_t mech_count;
 	uint32_t data_size;

Index: auth-master-connection.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/auth-master-connection.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- auth-master-connection.c	23 Jun 2004 17:50:44 -0000	1.8
+++ auth-master-connection.c	2 Jul 2004 22:03:37 -0000	1.9
@@ -226,7 +226,7 @@
 		mech_desc_offset += sizeof(mech_desc);
 	}
 
-	reply.data_size = buffer_get_used_size(buf);
+	reply.data_size = buffer_get_used_size(buf) - sizeof(reply);
 	memcpy(buffer_get_space_unsafe(buf, 0, sizeof(reply)),
 	       &reply, sizeof(reply));
 

Index: mech.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- mech.c	31 May 2004 20:10:02 -0000	1.26
+++ mech.c	2 Jul 2004 22:03:37 -0000	1.27
@@ -384,6 +384,7 @@
 }
 
 extern struct mech_module mech_plain;
+extern struct mech_module mech_apop;
 extern struct mech_module mech_cram_md5;
 extern struct mech_module mech_digest_md5;
 extern struct mech_module mech_anonymous;
@@ -411,6 +412,8 @@
 	while (*mechanisms != NULL) {
 		if (strcasecmp(*mechanisms, "PLAIN") == 0)
 			mech_register_module(&mech_plain);
+		else if (strcasecmp(*mechanisms, "APOP") == 0)
+			mech_register_module(&mech_apop);
 		else if (strcasecmp(*mechanisms, "CRAM-MD5") == 0)
 			mech_register_module(&mech_cram_md5);
 		else if (strcasecmp(*mechanisms, "DIGEST-MD5") == 0)
@@ -471,6 +474,7 @@
 	timeout_remove(to_auth_failures);
 
 	mech_unregister_module(&mech_plain);
+	mech_unregister_module(&mech_apop);
 	mech_unregister_module(&mech_cram_md5);
 	mech_unregister_module(&mech_digest_md5);
 	mech_unregister_module(&mech_anonymous);



More information about the dovecot-cvs mailing list