summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/tmux.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2009-09-23 06:18:47 +0000
committernicm <nicm@openbsd.org>2009-09-23 06:18:47 +0000
commit1c5425bdd24ac7c21379105499a9670138555d99 (patch)
tree3837fee2a7e136bdde425b4b70d80b34b49a11cb /usr.bin/tmux/tmux.c
parentTrim some code by moving the ioctl(TIOCGWINSZ) after SIGWINCH from the client (diff)
downloadwireguard-openbsd-1c5425bdd24ac7c21379105499a9670138555d99.tar.xz
wireguard-openbsd-1c5425bdd24ac7c21379105499a9670138555d99.zip
Remove the internal tmux locking and instead detach each client and run the
command specified by a new option "lock-command" (by default "lock -np") in each client. This means each terminal has to be unlocked individually but simplifies the code and allows the system password to be used to unlock. Note that the set-password command is gone, so it will need to be removed from configuration files, and the -U command line flag has been removed. This is the third protocol version change so again it is best to stop the tmux server before upgrading.
Diffstat (limited to 'usr.bin/tmux/tmux.c')
-rw-r--r--usr.bin/tmux/tmux.c60
1 files changed, 8 insertions, 52 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index f940b7d68b3..3163445aacc 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.44 2009/09/22 12:38:10 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.45 2009/09/23 06:18:48 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -46,11 +46,6 @@ struct options global_s_options; /* session options */
struct options global_w_options; /* window options */
struct environ global_environ;
-int server_locked;
-struct passwd *server_locked_pw;
-u_int password_failures;
-time_t password_backoff;
-char *server_password;
time_t server_activity;
int debug_level;
@@ -61,7 +56,6 @@ int login_shell;
__dead void usage(void);
char *makesockpath(const char *);
-int prepare_unlock(enum msgtype *, void **, size_t *, int);
int prepare_cmd(enum msgtype *, void **, size_t *, int, char **);
int dispatch_imsg(struct client_ctx *, int *);
@@ -69,7 +63,7 @@ __dead void
usage(void)
{
fprintf(stderr,
- "usage: %s [-28dlqUuv] [-f file] [-L socket-name]\n"
+ "usage: %s [-28dlquv] [-f file] [-L socket-name]\n"
" [-S socket-path] [command [flags]]\n",
__progname);
exit(1);
@@ -251,35 +245,6 @@ makesockpath(const char *label)
}
int
-prepare_unlock(enum msgtype *msg, void **buf, size_t *len, int argc)
-{
- static struct msg_unlock_data unlockdata;
- char *pass;
-
- if (argc != 0) {
- log_warnx("can't specify a command when unlocking");
- return (-1);
- }
-
- if ((pass = getpass("Password:")) == NULL)
- return (-1);
-
- if (strlen(pass) >= sizeof unlockdata.pass) {
- log_warnx("password too long");
- return (-1);
- }
-
- strlcpy(unlockdata.pass, pass, sizeof unlockdata.pass);
- memset(pass, 0, strlen(pass));
-
- *buf = &unlockdata;
- *len = sizeof unlockdata;
-
- *msg = MSG_UNLOCK;
- return (0);
-}
-
-int
prepare_cmd(enum msgtype *msg, void **buf, size_t *len, int argc, char **argv)
{
static struct msg_command_data cmddata;
@@ -314,10 +279,10 @@ main(int argc, char **argv)
char cwd[MAXPATHLEN];
void *buf;
size_t len;
- int retcode, opt, flags, unlock, cmdflags = 0;
+ int retcode, opt, flags, cmdflags = 0;
int nfds;
- unlock = flags = 0;
+ flags = 0;
label = path = NULL;
login_shell = (**argv == '-');
while ((opt = getopt(argc, argv, "28df:lL:qS:uUv")) != -1) {
@@ -357,9 +322,6 @@ main(int argc, char **argv)
case 'u':
flags |= IDENTIFY_UTF8;
break;
- case 'U':
- unlock = 1;
- break;
case 'v':
debug_level++;
break;
@@ -407,6 +369,7 @@ main(int argc, char **argv)
options_set_number(so, "display-time", 750);
options_set_number(so, "history-limit", 2000);
options_set_number(so, "lock-after-time", 0);
+ options_set_string(so, "lock-command", "lock -np");
options_set_number(so, "message-attr", 0);
options_set_number(so, "message-bg", 3);
options_set_number(so, "message-fg", 0);
@@ -514,17 +477,10 @@ main(int argc, char **argv)
}
xfree(label);
- if (unlock) {
- if (prepare_unlock(&msg, &buf, &len, argc) != 0)
- exit(1);
- } else {
- if (prepare_cmd(&msg, &buf, &len, argc, argv) != 0)
- exit(1);
- }
+ if (prepare_cmd(&msg, &buf, &len, argc, argv) != 0)
+ exit(1);
- if (unlock)
- cmdflags &= ~CMD_STARTSERVER;
- else if (argc == 0) /* new-session is the default */
+ if (argc == 0) /* new-session is the default */
cmdflags |= CMD_STARTSERVER|CMD_SENDENVIRON;
else {
/*