summaryrefslogtreecommitdiff
path: root/server/dispatch.c
diff options
context:
space:
mode:
authorGravatar Jeffrey Hutzelman <jhutz@cmu.edu>2013-02-23 03:34:06 -0500
committerGravatar Karl Ramm <kcr@1ts.org>2013-02-26 23:01:10 -0500
commit0fb2236580debdd37eeac27a5e0ae81d160400b4 (patch)
tree5358646305a76a51b2126b587735eb1e95804732 /server/dispatch.c
parent18e990a4f37a750ff71a2c5c9206afcd95df6208 (diff)
server: add CLIENT_FLUSHSUBS control message
This adds support to the server for a new client control message, CLIENT_FLUSHSUBS, which flushes all subscriptions and pending retransmits for clients belonging to a given principal. The target principal must be the same as the sender, unless the sender is on the opstaff ACL. This is the server side of #103
Diffstat (limited to 'server/dispatch.c')
-rw-r--r--server/dispatch.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/server/dispatch.c b/server/dispatch.c
index 9981581..b1909e0 100644
--- a/server/dispatch.c
+++ b/server/dispatch.c
@@ -966,7 +966,7 @@ control_dispatch(ZNotice_t *notice,
struct sockaddr_in *who,
Server *server)
{
- char *opcode = notice->z_opcode;
+ char *target, *opcode = notice->z_opcode;
Client *client;
Code_t retval;
int wantdefs;
@@ -1100,6 +1100,26 @@ control_dispatch(ZNotice_t *notice,
}
/* don't flush locations here, let him do it explicitly */
client_deregister(client, 0);
+ } else if (strcmp(opcode, CLIENT_FLUSHSUBS) == 0) {
+ target = notice->z_sender;
+ if (notice->z_message_len > 0 && *notice->z_message != 0) {
+ target = notice->z_message;
+ if (memchr(target, '\0', notice->z_message_len) == NULL) {
+ syslog(LOG_WARNING, "malformed flushsubs");
+ if (server == me_server)
+ nack(notice, who);
+ return ZERR_NONE;
+ }
+ if (strcmp(target, notice->z_sender) != 0 &&
+ !opstaff_check(notice->z_sender)) {
+ syslog(LOG_NOTICE, "unauth flushsubs for %s by %s",
+ target, notice->z_sender);
+ if (server == me_server)
+ clt_ack(notice, who, AUTH_FAILED);
+ return ZERR_NONE;
+ }
+ }
+ client_flush_princ(target);
} else {
syslog(LOG_WARNING, "unknown ctl opcode %s", opcode);
if (server == me_server) {