diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-01-11 00:48:42 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-01-11 00:48:42 +0000 |
commit | e3feb067a503b53da253e4ed877d212d6d73842c (patch) | |
tree | f0ebedf15d81253ae1d0437b6dc9f47cbccdc291 /server-msg.c | |
parent | ee0a7cda880f01771470b2902839c5d6396057c3 (diff) | |
download | rtmux-e3feb067a503b53da253e4ed877d212d6d73842c.tar.gz rtmux-e3feb067a503b53da253e4ed877d212d6d73842c.tar.bz2 rtmux-e3feb067a503b53da253e4ed877d212d6d73842c.zip |
Server locking. set-password and lock-server commands, plus automatic locking.
Diffstat (limited to 'server-msg.c')
-rw-r--r-- | server-msg.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/server-msg.c b/server-msg.c index 2f1fc681..1912a829 100644 --- a/server-msg.c +++ b/server-msg.c @@ -1,4 +1,4 @@ -/* $Id: server-msg.c,v 1.55 2009-01-10 19:37:35 nicm Exp $ */ +/* $Id: server-msg.c,v 1.56 2009-01-11 00:48:42 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -29,6 +29,7 @@ int server_msg_fn_command(struct hdr *, struct client *); int server_msg_fn_identify(struct hdr *, struct client *); int server_msg_fn_resize(struct hdr *, struct client *); int server_msg_fn_exiting(struct hdr *, struct client *); +int server_msg_fn_unlock(struct hdr *, struct client *); void printflike2 server_msg_fn_command_error( struct cmd_ctx *, const char *, ...); @@ -45,7 +46,8 @@ const struct server_msg server_msg_table[] = { { MSG_IDENTIFY, server_msg_fn_identify }, { MSG_COMMAND, server_msg_fn_command }, { MSG_RESIZE, server_msg_fn_resize }, - { MSG_EXITING, server_msg_fn_exiting } + { MSG_EXITING, server_msg_fn_exiting }, + { MSG_UNLOCK, server_msg_fn_unlock } }; int @@ -135,6 +137,7 @@ server_msg_fn_command(struct hdr *hdr, struct client *c) cmd = cmd_recv(c->in); log_debug("got command %s from client %d", cmd->entry->name, c->fd); + server_activity = time(NULL); ctx.error = server_msg_fn_command_error; ctx.print = server_msg_fn_command_print; @@ -244,3 +247,26 @@ server_msg_fn_exiting(struct hdr *hdr, struct client *c) return (0); } + +int +server_msg_fn_unlock(struct hdr *hdr, struct client *c) +{ + char *pass; + + if (hdr->size == 0) + fatalx("bad MSG_UNLOCK size"); + pass = cmd_recv_string(c->in); + + log_debug("unlock msg from client"); + + if (server_unlock(pass) != 0) { +#define MSG "bad password" + server_write_client(c, MSG_ERROR, MSG, (sizeof MSG) - 1); + return (0); +#undef MSG + } + + server_write_client(c, MSG_EXIT, NULL, 0); + + return (0); +} |