mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 21:56:57 +00:00
Sync OpenBSD patchset 347:
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.
This commit is contained in:
85
server.c
85
server.c
@ -1,4 +1,4 @@
|
||||
/* $Id: server.c,v 1.191 2009-09-22 14:22:20 tcunha Exp $ */
|
||||
/* $Id: server.c,v 1.192 2009-09-23 15:00:08 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -66,7 +66,6 @@ void server_lost_client(struct client *);
|
||||
void server_check_window(struct window *);
|
||||
void server_check_redraw(struct client *);
|
||||
void server_set_title(struct client *);
|
||||
void server_redraw_locked(struct client *);
|
||||
void server_check_timers(struct client *);
|
||||
void server_second_timers(void);
|
||||
int server_update_socket(void);
|
||||
@ -161,8 +160,6 @@ server_start(char *path)
|
||||
key_bindings_init();
|
||||
utf8_build();
|
||||
|
||||
server_locked = 0;
|
||||
server_password = NULL;
|
||||
server_activity = time(NULL);
|
||||
|
||||
start_time = time(NULL);
|
||||
@ -385,8 +382,6 @@ server_main(int srv_fd)
|
||||
|
||||
options_free(&global_s_options);
|
||||
options_free(&global_w_options);
|
||||
if (server_password != NULL)
|
||||
xfree(server_password);
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -544,10 +539,7 @@ server_check_redraw(struct client *c)
|
||||
}
|
||||
|
||||
if (c->flags & CLIENT_REDRAW) {
|
||||
if (server_locked)
|
||||
server_redraw_locked(c);
|
||||
else
|
||||
screen_redraw_screen(c, 0);
|
||||
screen_redraw_screen(c, 0);
|
||||
c->flags &= ~CLIENT_STATUS;
|
||||
} else {
|
||||
TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) {
|
||||
@ -584,49 +576,6 @@ server_set_title(struct client *c)
|
||||
xfree(title);
|
||||
}
|
||||
|
||||
/* Redraw client when locked. */
|
||||
void
|
||||
server_redraw_locked(struct client *c)
|
||||
{
|
||||
struct screen_write_ctx ctx;
|
||||
struct screen screen;
|
||||
struct grid_cell gc;
|
||||
u_int colour, xx, yy, i;
|
||||
int style;
|
||||
|
||||
xx = c->tty.sx;
|
||||
yy = c->tty.sy - 1;
|
||||
if (xx == 0 || yy == 0)
|
||||
return;
|
||||
colour = options_get_number(&global_w_options, "clock-mode-colour");
|
||||
style = options_get_number(&global_w_options, "clock-mode-style");
|
||||
|
||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||
colour_set_fg(&gc, colour);
|
||||
gc.attr |= GRID_ATTR_BRIGHT;
|
||||
|
||||
screen_init(&screen, xx, yy, 0);
|
||||
|
||||
screen_write_start(&ctx, NULL, &screen);
|
||||
clock_draw(&ctx, colour, style);
|
||||
|
||||
if (password_failures != 0) {
|
||||
screen_write_cursormove(&ctx, 0, 0);
|
||||
screen_write_puts(
|
||||
&ctx, &gc, "%u failed attempts", password_failures);
|
||||
if (time(NULL) < password_backoff)
|
||||
screen_write_puts(&ctx, &gc, "; sleeping");
|
||||
}
|
||||
|
||||
screen_write_stop(&ctx);
|
||||
|
||||
for (i = 0; i < screen_size_y(&screen); i++)
|
||||
tty_draw_line(&c->tty, &screen, i, 0, 0);
|
||||
screen_redraw_screen(c, 1);
|
||||
|
||||
screen_free(&screen);
|
||||
}
|
||||
|
||||
/* Check for timers on client. */
|
||||
void
|
||||
server_check_timers(struct client *c)
|
||||
@ -839,8 +788,6 @@ server_handle_client(struct client *c)
|
||||
status_prompt_key(c, key);
|
||||
continue;
|
||||
}
|
||||
if (server_locked)
|
||||
continue;
|
||||
|
||||
/* Check for mouse keys. */
|
||||
if (key == KEYC_MOUSE) {
|
||||
@ -932,8 +879,6 @@ server_handle_client(struct client *c)
|
||||
tty_cursor(&c->tty, s->cx, s->cy, wp->xoff, wp->yoff);
|
||||
|
||||
mode = s->mode;
|
||||
if (server_locked)
|
||||
mode &= ~TTY_NOCURSOR;
|
||||
tty_update_mode(&c->tty, mode);
|
||||
tty_reset(&c->tty);
|
||||
}
|
||||
@ -1238,12 +1183,9 @@ void
|
||||
server_second_timers(void)
|
||||
{
|
||||
struct window *w;
|
||||
struct client *c;
|
||||
struct window_pane *wp;
|
||||
u_int i;
|
||||
int xtimeout;
|
||||
struct tm now, then;
|
||||
static time_t last_t = 0;
|
||||
time_t t;
|
||||
|
||||
t = time(NULL);
|
||||
@ -1262,29 +1204,6 @@ server_second_timers(void)
|
||||
wp->mode->timer(wp);
|
||||
}
|
||||
}
|
||||
|
||||
if (password_backoff != 0 && t >= password_backoff) {
|
||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||
if ((c = ARRAY_ITEM(&clients, i)) != NULL)
|
||||
server_redraw_client(c);
|
||||
}
|
||||
password_backoff = 0;
|
||||
}
|
||||
|
||||
/* Check for a minute having passed. */
|
||||
gmtime_r(&t, &now);
|
||||
gmtime_r(&last_t, &then);
|
||||
if (now.tm_min == then.tm_min)
|
||||
return;
|
||||
last_t = t;
|
||||
|
||||
/* If locked, redraw all clients. */
|
||||
if (server_locked) {
|
||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||
if ((c = ARRAY_ITEM(&clients, i)) != NULL)
|
||||
server_redraw_client(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Update socket execute permissions based on whether sessions are attached. */
|
||||
|
Reference in New Issue
Block a user