Mercurial > dovecot > original-hg > dovecot-1.2
diff src/auth/auth-master-connection.c @ 2776:150f8151c971 HEAD
Added VERSION command and checking to authentication protocol.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 19 Oct 2004 03:51:21 +0300 |
parents | 3c3ac12be307 |
children | 02c0b8d532c2 |
line wrap: on
line diff
--- a/src/auth/auth-master-connection.c Tue Oct 19 03:42:07 2004 +0300 +++ b/src/auth/auth-master-connection.c Tue Oct 19 03:51:21 2004 +0300 @@ -10,6 +10,7 @@ #include "network.h" #include "mech.h" #include "userdb.h" +#include "auth-master-interface.h" #include "auth-client-connection.h" #include "auth-master-connection.h" @@ -168,6 +169,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_MASTER_PROTOCOL_MAJOR_VERSION) { + i_error("Master not compatible with this server " + "(mixed old and new binaries?)"); + auth_master_connection_close(conn); + return; + } + conn->version_received = TRUE; + } + while ((line = i_stream_next_line(conn->input)) != NULL) { t_push(); if (strncmp(line, "REQUEST\t", 8) == 0) @@ -241,10 +259,11 @@ void auth_master_connection_send_handshake(struct auth_master_connection *conn) { - /* just a note to master that we're ok. if we die before, it means - we're broken and a simple restart most likely won't help. */ - if (conn->output != NULL) - master_send(conn, "SPID\t%u", conn->pid); + if (conn->output != NULL) { + master_send(conn, "VERSION\t%u.%u\n", + AUTH_MASTER_PROTOCOL_MAJOR_VERSION, + AUTH_MASTER_PROTOCOL_MINOR_VERSION); + } } static void auth_master_connection_close(struct auth_master_connection *conn)