mirror of
https://github.com/tmux/tmux.git
synced 2025-01-15 05:09:04 +00:00
Change nested check to compare server socket path rather than just assuming
that if $TMUX is set it is nested. From Micah Cowan.
This commit is contained in:
parent
4a5017d1d8
commit
0a86d3579e
@ -693,17 +693,6 @@ server_client_msg_command(struct client *c, struct msg_command_data *data)
|
|||||||
}
|
}
|
||||||
cmd_free_argv(argc, argv);
|
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)
|
if (cmd_list_exec(cmdlist, &ctx) != 1)
|
||||||
server_write_client(c, MSG_EXIT, NULL, 0);
|
server_write_client(c, MSG_EXIT, NULL, 0);
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
|
17
tmux.c
17
tmux.c
@ -484,6 +484,7 @@ main(int argc, char **argv)
|
|||||||
cmddata.pid = envdata.pid;
|
cmddata.pid = envdata.pid;
|
||||||
cmddata.idx = envdata.idx;
|
cmddata.idx = envdata.idx;
|
||||||
|
|
||||||
|
/* Prepare command for server. */
|
||||||
cmddata.argc = argc;
|
cmddata.argc = argc;
|
||||||
if (cmd_pack_argv(
|
if (cmd_pack_argv(
|
||||||
argc, argv, cmddata.argv, sizeof cmddata.argv) != 0) {
|
argc, argv, cmddata.argv, sizeof cmddata.argv) != 0) {
|
||||||
@ -499,7 +500,7 @@ main(int argc, char **argv)
|
|||||||
if (shellcmd != NULL)
|
if (shellcmd != NULL)
|
||||||
cmdflags |= CMD_STARTSERVER;
|
cmdflags |= CMD_STARTSERVER;
|
||||||
else if (argc == 0) /* new-session is the default */
|
else if (argc == 0) /* new-session is the default */
|
||||||
cmdflags |= CMD_STARTSERVER|CMD_SENDENVIRON;
|
cmdflags |= CMD_STARTSERVER|CMD_SENDENVIRON|CMD_CANTNEST;
|
||||||
else {
|
else {
|
||||||
/*
|
/*
|
||||||
* It sucks parsing the command string twice (in client and
|
* It sucks parsing the command string twice (in client and
|
||||||
@ -516,10 +517,24 @@ main(int argc, char **argv)
|
|||||||
cmdflags |= CMD_STARTSERVER;
|
cmdflags |= CMD_STARTSERVER;
|
||||||
if (cmd->entry->flags & CMD_SENDENVIRON)
|
if (cmd->entry->flags & CMD_SENDENVIRON)
|
||||||
cmdflags |= CMD_SENDENVIRON;
|
cmdflags |= CMD_SENDENVIRON;
|
||||||
|
if (cmd->entry->flags & CMD_CANTNEST)
|
||||||
|
cmdflags |= CMD_CANTNEST;
|
||||||
}
|
}
|
||||||
cmd_list_free(cmdlist);
|
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)
|
if ((main_ibuf = client_init(path, cmdflags, flags)) == NULL)
|
||||||
exit(1);
|
exit(1);
|
||||||
xfree(path);
|
xfree(path);
|
||||||
|
Loading…
Reference in New Issue
Block a user