[dovecot-cvs] dovecot/src/lib-auth auth-server-connection.c, 1.9, 1.10 auth-server-connection.h, 1.6, 1.7

cras at dovecot.org cras at dovecot.org
Tue Oct 19 03:51:23 EEST 2004


Update of /var/lib/cvs/dovecot/src/lib-auth
In directory talvi:/tmp/cvs-serv16627/lib-auth

Modified Files:
	auth-server-connection.c auth-server-connection.h 
Log Message:
Added VERSION command and checking to authentication protocol.



Index: auth-server-connection.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-auth/auth-server-connection.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- auth-server-connection.c	13 Oct 2004 16:38:34 -0000	1.9
+++ auth-server-connection.c	19 Oct 2004 00:51:21 -0000	1.10
@@ -140,6 +140,23 @@
 		return;
 	}
 
+	if (conn->version_received) {
+		line = i_stream_next_line(conn->input);
+		if (line == NULL)
+			return;
+
+		/* make sure the major version matches */
+		if (strncmp(line, "VERSION\t", 8) != 0 ||
+		    atoi(t_strcut(line + 8, '.')) !=
+		    AUTH_CLIENT_PROTOCOL_MAJOR_VERSION) {
+			i_error("Authentication server not compatible with "
+				"this client (mixed old and new binaries?)");
+			auth_server_connection_destroy(conn, FALSE);
+			return;
+		}
+		conn->version_received = TRUE;
+	}
+
 	conn->refcount++;
 	while ((line = i_stream_next_line(conn->input)) != NULL) {
 		if (strncmp(line, "OK\t", 3) == 0)
@@ -173,6 +190,7 @@
 auth_server_connection_new(struct auth_client *client, const char *path)
 {
 	struct auth_server_connection *conn;
+	const char *handshake;
 	pool_t pool;
 	int fd;
 
@@ -209,9 +227,13 @@
 	conn->next = client->connections;
 	client->connections = conn;
 
+	handshake = t_strdup_printf("VERSION\t%u.%u\nCPID\t%u\n",
+				    AUTH_CLIENT_PROTOCOL_MAJOR_VERSION,
+                                    AUTH_CLIENT_PROTOCOL_MINOR_VERSION,
+				    client->pid);
+
         client->conn_waiting_handshake_count++;
-	if (o_stream_send_str(conn->output,
-			      t_strdup_printf("CPID\t%u\n", client->pid)) < 0) {
+	if (o_stream_send_str(conn->output, handshake) < 0) {
 		errno = conn->output->stream_errno;
 		i_warning("Error sending handshake to auth server: %m");
 		auth_server_connection_destroy(conn, TRUE);

Index: auth-server-connection.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-auth/auth-server-connection.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- auth-server-connection.h	13 Oct 2004 16:38:34 -0000	1.6
+++ auth-server-connection.h	19 Oct 2004 00:51:21 -0000	1.7
@@ -46,6 +46,7 @@
 
         struct hash_table *requests;
 
+	unsigned int version_received:1;
 	unsigned int handshake_received:1;
 	unsigned int has_plain_mech:1;
 };



More information about the dovecot-cvs mailing list