diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-02-06 18:47:42 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-02-06 18:47:42 +0000 |
commit | 5c8fb2a4ce4ebf89e7f1f8c12cf3d7fce7c5315a (patch) | |
tree | 80c5aa54809663ba21d7e71d0aad8c6af71459ae /usr.bin/tmux | |
parent | 893b71ee5211f9ac8a5550421f6021d25f2cec25 (diff) |
Change nested check to compare server socket path rather than just assuming
that if $TMUX is set it is nested. From Micah Cowan.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/server-client.c | 13 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.c | 19 |
2 files changed, 18 insertions, 14 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 988e511c8a8..331e4137211 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.28 2010/01/08 09:14:15 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.29 2010/02/06 18:47:41 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -693,17 +693,6 @@ server_client_msg_command(struct client *c, struct msg_command_data *data) } cmd_free_argv(argc, argv); - if (data->pid != -1) { - TAILQ_FOREACH(cmd, cmdlist, qentry) { - if (cmd->entry->flags & CMD_CANTNEST) { - server_client_msg_error(&ctx, - "sessions should be nested with care. " - "unset $TMUX to force"); - goto error; - } - } - } - if (cmd_list_exec(cmdlist, &ctx) != 1) server_write_client(c, MSG_EXIT, NULL, 0); cmd_list_free(cmdlist); diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index 7918c8ae5f7..e79d2425e78 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.70 2010/02/06 18:29:15 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.71 2010/02/06 18:47:41 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -484,6 +484,7 @@ main(int argc, char **argv) cmddata.pid = envdata.pid; cmddata.idx = envdata.idx; + /* Prepare command for server. */ cmddata.argc = argc; if (cmd_pack_argv( argc, argv, cmddata.argv, sizeof cmddata.argv) != 0) { @@ -499,7 +500,7 @@ main(int argc, char **argv) if (shellcmd != NULL) cmdflags |= CMD_STARTSERVER; else if (argc == 0) /* new-session is the default */ - cmdflags |= CMD_STARTSERVER|CMD_SENDENVIRON; + cmdflags |= CMD_STARTSERVER|CMD_SENDENVIRON|CMD_CANTNEST; else { /* * It sucks parsing the command string twice (in client and @@ -516,10 +517,24 @@ main(int argc, char **argv) cmdflags |= CMD_STARTSERVER; if (cmd->entry->flags & CMD_SENDENVIRON) cmdflags |= CMD_SENDENVIRON; + if (cmd->entry->flags & CMD_CANTNEST) + cmdflags |= CMD_CANTNEST; } cmd_list_free(cmdlist); } + /* + * Check if this could be a nested session, if the command can't nest: + * if the socket path matches $TMUX, this is probably the same server. + */ + if (shellcmd == NULL && envdata.path != NULL && + cmdflags & CMD_CANTNEST && + (path == envdata.path || strcmp(path, envdata.path) == 0)) { + log_warnx("sessions should be nested with care. " + "unset $TMUX to force."); + exit(1); + } + if ((main_ibuf = client_init(path, cmdflags, flags)) == NULL) exit(1); xfree(path); |