Mercurial > dovecot > original-hg > dovecot-1.2
changeset 2779:1fd55b4341b9 HEAD
Added version to login <-> master communication as well.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 19 Oct 2004 04:17:39 +0300 |
parents | b85e7c414f06 |
children | 4ff5b3e8ee51 |
files | src/login-common/master.c src/master/login-process.c src/master/master-login-interface.h |
diffstat | 3 files changed, 19 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/login-common/master.c Tue Oct 19 04:17:20 2004 +0300 +++ b/src/login-common/master.c Tue Oct 19 04:17:39 2004 +0300 @@ -44,6 +44,7 @@ i_assert(auth_pid != 0); memset(&req, 0, sizeof(req)); + req.version = MASTER_LOGIN_PROTOCOL_VERSION; req.tag = ++master_tag_counter; if (req.tag == 0) req.tag = ++master_tag_counter; @@ -77,6 +78,7 @@ return; memset(&req, 0, sizeof(req)); + req.version = MASTER_LOGIN_PROTOCOL_VERSION; /* sending -1 as fd does the notification */ if (fd_send(master_fd, -1, &req, sizeof(req)) != sizeof(req))
--- a/src/master/login-process.c Tue Oct 19 04:17:20 2004 +0300 +++ b/src/master/login-process.c Tue Oct 19 04:17:39 2004 +0300 @@ -238,6 +238,14 @@ } ret = fd_read(p->fd, &req, sizeof(req), &client_fd); + if (ret >= (ssize_t)sizeof(req.version) && + req.version != MASTER_LOGIN_PROTOCOL_VERSION) { + i_error("login: Protocol version mismatch " + "(mixed old and new binaries?)"); + login_process_destroy(p); + return; + } + if (ret != sizeof(req)) { if (ret == 0) { /* disconnected, ie. the login process died */
--- a/src/master/master-login-interface.h Tue Oct 19 04:17:20 2004 +0300 +++ b/src/master/master-login-interface.h Tue Oct 19 04:17:39 2004 +0300 @@ -7,11 +7,16 @@ #define LOGIN_SSL_LISTEN_FD 1 #define LOGIN_MASTER_SOCKET_FD 3 -struct master_login_request { - unsigned int tag; +/* Increase the version number every time master_login_request + (or something else) is changed. */ +#define MASTER_LOGIN_PROTOCOL_VERSION 1 - unsigned int auth_pid; - unsigned int auth_id; +struct master_login_request { + uint32_t version; + uint32_t tag; + + uint32_t auth_pid; + uint32_t auth_id; struct ip_addr local_ip, remote_ip; };