summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/cmd-set-option.c9
-rw-r--r--usr.bin/tmux/server-client.c6
-rw-r--r--usr.bin/tmux/spawn.c4
-rw-r--r--usr.bin/tmux/tmux.c8
-rw-r--r--usr.bin/tmux/tmux.h4
5 files changed, 20 insertions, 11 deletions
diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c
index 55691d015d1..c91f623d665 100644
--- a/usr.bin/tmux/cmd-set-option.c
+++ b/usr.bin/tmux/cmd-set-option.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-set-option.c,v 1.127 2019/06/20 11:59:59 nicm Exp $ */
+/* $OpenBSD: cmd-set-option.c,v 1.128 2020/03/17 11:10:12 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -309,6 +309,13 @@ cmd_set_option_set(struct cmd *self, struct cmdq_item *item, struct options *oo,
old = xstrdup(options_get_string(oo, oe->name));
options_set_string(oo, oe->name, append, "%s", value);
new = options_get_string(oo, oe->name);
+ if (strcmp(oe->name, "default-shell") == 0 &&
+ !checkshell(new)) {
+ options_set_string(oo, oe->name, 0, "%s", old);
+ free(old);
+ cmdq_error(item, "not a suitable shell: %s", value);
+ return (-1);
+ }
if (oe->pattern != NULL && fnmatch(oe->pattern, new, 0) != 0) {
options_set_string(oo, oe->name, 0, "%s", old);
free(old);
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index c33be44fa0b..f4666cd704f 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.307 2020/03/16 06:12:42 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.308 2020/03/17 11:10:12 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -400,6 +400,8 @@ server_client_exec(struct client *c, const char *cmd)
shell = options_get_string(s->options, "default-shell");
else
shell = options_get_string(global_s_options, "default-shell");
+ if (!checkshell(shell))
+ shell = _PATH_BSHELL;
shellsize = strlen(shell) + 1;
msg = xmalloc(cmdsize + shellsize);
@@ -2009,7 +2011,7 @@ server_client_dispatch_shell(struct client *c)
const char *shell;
shell = options_get_string(global_s_options, "default-shell");
- if (*shell == '\0' || areshell(shell))
+ if (!checkshell(shell))
shell = _PATH_BSHELL;
proc_send(c->peer, MSG_SHELL, -1, shell, strlen(shell) + 1);
diff --git a/usr.bin/tmux/spawn.c b/usr.bin/tmux/spawn.c
index 6cbd837c14b..915640f2e8e 100644
--- a/usr.bin/tmux/spawn.c
+++ b/usr.bin/tmux/spawn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spawn.c,v 1.15 2020/03/02 08:30:30 nicm Exp $ */
+/* $OpenBSD: spawn.c,v 1.16 2020/03/17 11:10:12 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -320,7 +320,7 @@ spawn_pane(struct spawn_context *sc, char **cause)
/* Then the shell. If respawning, use the old one. */
if (~sc->flags & SPAWN_RESPAWN) {
tmp = options_get_string(s->options, "default-shell");
- if (*tmp == '\0' || areshell(tmp))
+ if (!checkshell(tmp))
tmp = _PATH_BSHELL;
free(new_wp->shell);
new_wp->shell = xstrdup(tmp);
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index 576409c0bd1..b75d851d381 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.193 2020/03/12 09:26:34 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.194 2020/03/17 11:10:12 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -49,8 +49,8 @@ const char *shell_command;
static __dead void usage(void);
static char *make_label(const char *, char **);
+static int areshell(const char *);
static const char *getshell(void);
-static int checkshell(const char *);
static __dead void
usage(void)
@@ -79,7 +79,7 @@ getshell(void)
return (_PATH_BSHELL);
}
-static int
+int
checkshell(const char *shell)
{
if (shell == NULL || *shell != '/')
@@ -91,7 +91,7 @@ checkshell(const char *shell)
return (1);
}
-int
+static int
areshell(const char *shell)
{
const char *progname, *ptr;
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 188e7ae5557..4913274c9d6 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.958 2020/03/16 06:12:43 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.959 2020/03/17 11:10:12 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1771,7 +1771,7 @@ extern const char *socket_path;
extern const char *shell_command;
extern int ptm_fd;
extern const char *shell_command;
-int areshell(const char *);
+int checkshell(const char *);
void setblocking(int, int);
const char *find_cwd(void);
const char *find_home(void);