From 64d7e30f97ea4996426d227734b7a337f2f80b88 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Mon, 15 Jul 2013 11:24:28 +0200 Subject: [PATCH] Change method dispatch in ClientOps to enforce luxi.REQ_ALL ClientOps' handle_request dispatches on the luxi request received. Change this to first verify if the request is luxi.REQ_ALL. In this way, we catch programming errors introducing "secret" luxi requests earlier. This is relevant, as our other checks for internal consistency compare against luxi.REQ_ALL. Signed-off-by: Klaus Aehlig Reviewed-by: Michele Tartara --- lib/server/masterd.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/server/masterd.py b/lib/server/masterd.py index 8b52c35..b0e8708 100644 --- a/lib/server/masterd.py +++ b/lib/server/masterd.py @@ -279,6 +279,10 @@ class ClientOps: logging.info("Received invalid arguments of type '%s'", type(args)) raise ValueError("Invalid arguments type '%s'" % type(args)) + if method not in luxi.REQ_ALL: + logging.info("Received invalid request '%s'", method) + raise ValueError("Invalid operation '%s'" % method) + # TODO: Rewrite to not exit in each 'if/elif' branch if method == luxi.REQ_SUBMIT_JOB: @@ -446,8 +450,9 @@ class ClientOps: return _SetWatcherPause(context, until) else: - logging.info("Received invalid request '%s'", method) - raise ValueError("Invalid operation '%s'" % method) + logging.critical("Request '%s' in luxi.REQ_ALL, but not known", method) + raise errors.ProgrammerError("Operation '%s' in luxi.REQ_ALL," + " but not implemented" % method) def _Query(self, op): """Runs the specified opcode and returns the result. -- 1.7.10.4