summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-09-23 06:05:02 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-09-23 06:05:02 +0000
commit64caf59e84c3ae1c06773bb8ec91165eeedabe6d (patch)
tree0f10d742fde77ea6c07b28a3675caaad14595db8 /client.c
parent0a9005678da04b1e7783d26b02041e3973f26127 (diff)
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.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/client.c b/client.c
index 05d5b606..ee3bba50 100644
--- a/client.c
+++ b/client.c
@@ -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;
char rpathbuf[MAXPATHLEN];
if (realpath(path, rpathbuf) == NULL)
@@ -113,13 +113,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);
}