summaryrefslogtreecommitdiffstats
path: root/server-fn.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-09-24 14:17:09 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-09-24 14:17:09 +0000
commit8fa1858a2c02aafa31695a12fa40cd5dbdd53cd2 (patch)
treeabec88eed0aa73acb73d0cb95a5bb684a4a94cce /server-fn.c
parent1764ef81efce5f265f61107f0b1e91d73b858fb4 (diff)
New lock-client and lock-session commands to lock an individual client or all
clients attached to a session respectively.
Diffstat (limited to 'server-fn.c')
-rw-r--r--server-fn.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/server-fn.c b/server-fn.c
index b9be1794..6acca2bf 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -157,10 +157,8 @@ server_status_window(struct window *w)
void
server_lock(void)
{
- struct client *c;
- const char *cmd;
- struct msg_lock_data lockdata;
- u_int i;
+ struct client *c;
+ u_int i;
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
@@ -168,19 +166,44 @@ server_lock(void)
continue;
if (c->flags & CLIENT_SUSPENDED)
continue;
+ server_lock_client(c);
+ }
+}
- cmd = options_get_string(&c->session->options, "lock-command");
- if (strlcpy(lockdata.cmd,
- cmd, sizeof lockdata.cmd) >= sizeof lockdata.cmd)
+void
+server_lock_session(struct session *s)
+{
+ struct client *c;
+ u_int i;
+
+ for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
+ c = ARRAY_ITEM(&clients, i);
+ if (c == NULL || c->session == NULL || c->session != s)
+ continue;
+ if (c->flags & CLIENT_SUSPENDED)
continue;
+ server_lock_client(c);
+ }
+}
- tty_stop_tty(&c->tty);
- tty_raw(&c->tty, tty_term_string(c->tty.term, TTYC_SMCUP));
- tty_raw(&c->tty, tty_term_string(c->tty.term, TTYC_CLEAR));
+void
+server_lock_client(struct client *c)
+{
+ const char *cmd;
+ size_t cmdlen;
+ struct msg_lock_data lockdata;
- c->flags |= CLIENT_SUSPENDED;
- server_write_client(c, MSG_LOCK, &lockdata, sizeof lockdata);
- }
+ cmd = options_get_string(&c->session->options, "lock-command");
+ cmdlen = strlcpy(lockdata.cmd, cmd, sizeof lockdata.cmd);
+ if (cmdlen >= sizeof lockdata.cmd)
+ return;
+
+ tty_stop_tty(&c->tty);
+ tty_raw(&c->tty, tty_term_string(c->tty.term, TTYC_SMCUP));
+ tty_raw(&c->tty, tty_term_string(c->tty.term, TTYC_CLEAR));
+
+ c->flags |= CLIENT_SUSPENDED;
+ server_write_client(c, MSG_LOCK, &lockdata, sizeof lockdata);
}
void