aboutsummaryrefslogtreecommitdiff
path: root/tmux.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-09-23 06:18:47 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-09-23 06:18:47 +0000
commitb01dcd79715d968cb39dc892215c2f6921d43974 (patch)
tree1ccd6b4de2d9910d190fc42917d751a92edba628 /tmux.c
parent962fa20b36cc6d38d9a44612441f3f706c29b71e (diff)
downloadrtmux-b01dcd79715d968cb39dc892215c2f6921d43974.tar.gz
rtmux-b01dcd79715d968cb39dc892215c2f6921d43974.tar.bz2
rtmux-b01dcd79715d968cb39dc892215c2f6921d43974.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 'tmux.c')
-rw-r--r--tmux.c58
1 files changed, 7 insertions, 51 deletions
diff --git a/tmux.c b/tmux.c
index 02657e32..bde1e7f2 100644
--- a/tmux.c
+++ b/tmux.c
@@ -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 {
/*