diff options
author | Tiago Cunha <tcunha@gmx.com> | 2010-02-08 18:25:04 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2010-02-08 18:25:04 +0000 |
commit | 9b57743cca71a7b2313a8d4f41558e8ec0404d9b (patch) | |
tree | c09bf235911cf2026c62b31fd7ed868d03c6c5f5 /tmux.c | |
parent | ac8aa0bc0f80a2121a7d799a56a0d3ce4bf435b4 (diff) | |
download | rtmux-9b57743cca71a7b2313a8d4f41558e8ec0404d9b.tar.gz rtmux-9b57743cca71a7b2313a8d4f41558e8ec0404d9b.tar.bz2 rtmux-9b57743cca71a7b2313a8d4f41558e8ec0404d9b.zip |
Sync OpenBSD patchset 638:
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 'tmux.c')
-rw-r--r-- | tmux.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.201 2010-02-08 18:23:48 tcunha Exp $ */ +/* $Id: tmux.c,v 1.202 2010-02-08 18:25:04 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -487,6 +487,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) { @@ -502,7 +503,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 @@ -519,10 +520,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); |