summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-09-23 14:39:30 +0000
committerTiago Cunha <tcunha@gmx.com>2009-09-23 14:39:30 +0000
commitacedc2dcf2673cf199ba1ba08705dc8fd270c0c7 (patch)
treef51d5c52a93e0f6f2fba161d87e0cd0ac7230ea0 /client.c
parentc40d8cbda4c391008b4c46d211d6f3c09accd81a (diff)
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 'client.c')
-rw-r--r--client.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/client.c b/client.c
index 75e46b28..ffaded72 100644
--- a/client.c
+++ b/client.c
@@ -1,4 +1,4 @@
-/* $Id: client.c,v 1.71 2009-09-20 22:11:27 tcunha Exp $ */
+/* $Id: client.c,v 1.72 2009-09-23 14:39:30 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -45,7 +45,7 @@ client_init(char *path, struct client_ctx *cctx, int cmdflags, int flags)
struct winsize ws;
size_t size;
int fd, fd2, mode;
- char *name, *term;
+ char *term;
#ifdef HAVE_SETPROCTITLE
char rpathbuf[MAXPATHLEN];
#endif
@@ -117,13 +117,8 @@ server_started:
*data.term = '\0';
}
- *data.tty = '\0';
- if ((name = ttyname(STDIN_FILENO)) == NULL)
- fatal("ttyname failed");
- if (strlcpy(data.tty, name, sizeof data.tty) >= sizeof data.tty)
- fatalx("ttyname failed");
-
- fd2 = dup(STDIN_FILENO);
+ if ((fd2 = dup(STDIN_FILENO)) == -1)
+ fatal("dup failed");
imsg_compose(&cctx->ibuf, MSG_IDENTIFY,
PROTOCOL_VERSION, -1, fd2, &data, sizeof data);
}