[dovecot-cvs] dovecot/src/master auth-process.c,1.63,1.64

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


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

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



Index: auth-process.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/auth-process.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- auth-process.c	15 Oct 2004 22:55:35 -0000	1.63
+++ auth-process.c	19 Oct 2004 00:51:22 -0000	1.64
@@ -11,6 +11,7 @@
 #include "restrict-access.h"
 #include "restrict-process-size.h"
 #include "auth-process.h"
+#include "../auth/auth-master-interface.h"
 #include "log.h"
 
 #include <stdlib.h>
@@ -135,27 +136,6 @@
 }
 
 static int
-auth_process_input_spid(struct auth_process *process, const char *args)
-{
-	unsigned int pid;
-
-	if (process->initialized) {
-		i_error("BUG: Authentication server re-handshaking");
-		return FALSE;
-	}
-
-	pid = (unsigned int)strtoul(args, NULL, 10);
-	if (pid == 0) {
-		i_error("BUG: Authentication server said it's PID 0");
-		return FALSE;
-	}
-
-	process->pid = pid;
-	process->initialized = TRUE;
-	return TRUE;
-}
-
-static int
 auth_process_input_fail(struct auth_process *process, const char *args)
 {
 	void *context;
@@ -202,6 +182,24 @@
 		return;
 	}
 
+	if (!process->initialized) {
+		line = i_stream_next_line(process->input);
+		if (line == NULL)
+			return;
+
+		/* make sure the major version matches */
+		if (strncmp(line, "VERSION\t", 8) != 0 ||
+		    atoi(t_strcut(line + 8, '.')) !=
+		    AUTH_MASTER_PROTOCOL_MAJOR_VERSION) {
+			i_error("Auth process %s not compatible with master "
+				"process (mixed old and new binaries?)",
+				dec2str(process->pid));
+			auth_process_destroy(process);
+			return;
+		}
+		process->initialized = TRUE;
+	}
+
 	while ((line = i_stream_next_line(process->input)) != NULL) {
 		t_push();
 		if (strncmp(line, "USER\t", 5) == 0)
@@ -210,8 +208,6 @@
 			ret = auth_process_input_notfound(process, line + 9);
 		else if (strncmp(line, "FAIL\t", 5) == 0)
 			ret = auth_process_input_fail(process, line + 5);
-		else if (strncmp(line, "SPID\t", 5) == 0)
-			ret = auth_process_input_spid(process, line + 5);
 		else
 			ret = TRUE;
 		t_pop();



More information about the dovecot-cvs mailing list