Protocol versioning, version is checked on identify message.

This commit is contained in:
Nicholas Marriott 2008-07-01 19:47:02 +00:00
parent 87b9851f3a
commit dd41035a4d
4 changed files with 20 additions and 6 deletions

View File

@ -1,5 +1,7 @@
01 July 2008
* Protocol versioning. Clients which identify as a different version from the
server will be rejected.
* tmux 0.4 released.
29 June 2008
@ -596,4 +598,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
$Id: CHANGES,v 1.147 2008-07-01 05:43:00 nicm Exp $
$Id: CHANGES,v 1.148 2008-07-01 19:47:02 nicm Exp $

View File

@ -1,4 +1,4 @@
/* $Id: client.c,v 1.33 2008-06-23 16:58:49 nicm Exp $ */
/* $Id: client.c,v 1.34 2008-07-01 19:47:02 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -93,6 +93,7 @@ retry:
if (isatty(STDIN_FILENO)) {
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1)
fatal("ioctl(TIOCGWINSZ)");
data.version = PROTOCOL_VERSION;
data.sx = ws.ws_col;
data.sy = ws.ws_row;
*data.tty = '\0';

View File

@ -1,4 +1,4 @@
/* $Id: server-msg.c,v 1.48 2008-06-21 10:19:36 nicm Exp $ */
/* $Id: server-msg.c,v 1.49 2008-07-01 19:47:02 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -172,7 +172,15 @@ server_msg_fn_identify(struct hdr *hdr, struct client *c)
buffer_read(c->in, &data, sizeof data);
term = cmd_recv_string(c->in);
log_debug("identify msg from client: %u,%u", data.sx, data.sy);
log_debug("identify msg from client: %u,%u (%d)",
data.sx, data.sy, data.version);
if (data.version != PROTOCOL_VERSION) {
#define MSG "protocol version mismatch"
server_write_client(c, MSG_ERROR, MSG, (sizeof MSG) - 1);
#undef MSG
return (0);
}
c->sx = data.sx;
c->sy = data.sy;

7
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.172 2008-06-30 05:34:06 nicm Exp $ */
/* $Id: tmux.h,v 1.173 2008-07-01 19:47:02 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -19,6 +19,8 @@
#ifndef TMUX_H
#define TMUX_H
#define PROTOCOL_VERSION -1
/* Shut up gcc warnings about empty if bodies. */
#define RB_AUGMENT(x) do {} while (0)
@ -330,7 +332,7 @@ struct buffer {
#define TTY_KKEYPADOFF 22
#define TTY_KKEYPADON 23
#define TTY_MOUSEON 24
#define TTY_MOUSEOFF 25 /* XXX merge allon/off into 1 arg? */
#define TTY_MOUSEOFF 25 /* XXX merge all on/off into 1 arg? */
/* Message codes. */
enum hdrtype {
@ -361,6 +363,7 @@ struct msg_command_data {
struct msg_identify_data {
char tty[TTY_NAME_MAX];
int version;
u_int sx;
u_int sy;