From b692b00052383b6be4c1f7a72505a59103253db5 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 6 May 2021 09:22:09 +0000 Subject: Some more boilerplate --- src/server/command.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/server/command.c b/src/server/command.c index 9127714..59fd970 100644 --- a/src/server/command.c +++ b/src/server/command.c @@ -18,6 +18,8 @@ static inline int answer (client_t *c, char e) static int do_query (client_t *c, char const *s, size_t len) { if (!len--) return (errno = EPROTO, 0) ; + if (!(c->flags & 2)) return answer(c, EPERM) ; + /* TODO */ return 1 ; } @@ -71,16 +73,25 @@ static int do_monitor (client_t *c, char const *s, size_t len) static int do_change (client_t *c, char const *s, size_t len) { + if (!len--) return (errno = EPROTO, 0) ; + if (!(c->flags & 4)) return answer(c, EPERM) ; + /* TODO */ return 1 ; } static int do_event (client_t *c, char const *s, size_t len) { + if (!len--) return (errno = EPROTO, 0) ; + if (!(c->flags & 8)) return answer(c, EPERM) ; + /* TODO */ return 1 ; } static int do_admin (client_t *c, char const *s, size_t len) { + if (!len--) return (errno = EPROTO, 0) ; + if (!(c->flags & 16)) return answer(c, EPERM) ; + /* TODO */ return 1 ; } -- cgit v1.2.3