diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-09-23 14:39:30 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-09-23 14:39:30 +0000 |
commit | acedc2dcf2673cf199ba1ba08705dc8fd270c0c7 (patch) | |
tree | f51d5c52a93e0f6f2fba161d87e0cd0ac7230ea0 /server-msg.c | |
parent | c40d8cbda4c391008b4c46d211d6f3c09accd81a (diff) | |
download | rtmux-acedc2dcf2673cf199ba1ba08705dc8fd270c0c7.tar.gz rtmux-acedc2dcf2673cf199ba1ba08705dc8fd270c0c7.tar.bz2 rtmux-acedc2dcf2673cf199ba1ba08705dc8fd270c0c7.zip |
Sync OpenBSD patchset 345:
Don't attempt to open() the tty path, rely on the client sending its stdin fd
with imsg and fatal if it doesn't, then set the FD_CLOEXEC flag in tty_init
instead of tty_open to prevent them leaking into child processes if any are
created between the two calls.
This bumps the protocol version, so the tmux server should be killed before
upgrading.
Diffstat (limited to 'server-msg.c')
-rw-r--r-- | server-msg.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/server-msg.c b/server-msg.c index b79fe215..5ed956ac 100644 --- a/server-msg.c +++ b/server-msg.c @@ -1,4 +1,4 @@ -/* $Id: server-msg.c,v 1.84 2009-09-15 23:52:30 tcunha Exp $ */ +/* $Id: server-msg.c,v 1.85 2009-09-23 14:39:30 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -74,6 +74,8 @@ server_msg_dispatch(struct client *c) case MSG_IDENTIFY: if (datalen != sizeof identifydata) fatalx("bad MSG_IDENTIFY size"); + if (imsg.fd == -1) + fatalx("MSG_IDENTIFY missing fd"); memcpy(&identifydata, imsg.data, sizeof identifydata); server_msg_identify(c, &identifydata, imsg.fd); @@ -243,21 +245,13 @@ error: void server_msg_identify(struct client *c, struct msg_identify_data *data, int fd) { - c->tty.sx = data->sx; - if (c->tty.sx == 0) - c->tty.sx = 80; - c->tty.sy = data->sy; - if (c->tty.sy == 0) - c->tty.sy = 24; - c->cwd = NULL; data->cwd[(sizeof data->cwd) - 1] = '\0'; if (*data->cwd != '\0') c->cwd = xstrdup(data->cwd); - data->tty[(sizeof data->tty) - 1] = '\0'; data->term[(sizeof data->term) - 1] = '\0'; - tty_init(&c->tty, fd, data->tty, data->term); + tty_init(&c->tty, fd, data->term); if (data->flags & IDENTIFY_UTF8) c->tty.flags |= TTY_UTF8; if (data->flags & IDENTIFY_256COLOURS) @@ -267,6 +261,13 @@ server_msg_identify(struct client *c, struct msg_identify_data *data, int fd) if (data->flags & IDENTIFY_HASDEFAULTS) c->tty.term_flags |= TERM_HASDEFAULTS; + c->tty.sx = data->sx; + if (c->tty.sx == 0) + c->tty.sx = 80; + c->tty.sy = data->sy; + if (c->tty.sy == 0) + c->tty.sy = 24; + c->flags |= CLIENT_TERMINAL; } |