From 6c994f6c9c5357716fb6449378ee739bdd3d57ab Mon Sep 17 00:00:00 2001 From: Arksine Date: Sat, 27 Feb 2021 20:05:22 -0500 Subject: [PATCH] machine: add webcamd to the list of allowed services Signed-off-by: Eric Callahan --- moonraker/plugins/machine.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/moonraker/plugins/machine.py b/moonraker/plugins/machine.py index 14c834e..9866413 100644 --- a/moonraker/plugins/machine.py +++ b/moonraker/plugins/machine.py @@ -6,6 +6,8 @@ import logging from tornado.ioloop import IOLoop +ALLOWED_SERVICES = ["moonraker", "klipper", "webcamd"] + class Machine: def __init__(self, config): self.server = config.get_server() @@ -43,11 +45,11 @@ class Machine: await self._execute_cmd(f'sudo systemctl restart {service_name}') async def _handle_service_restart(self, web_request): - name = web_request.get('service') - if name == "klipper": - await self.restart_service(name) - elif name == "moonraker": + name = web_request.get('service').lower() + if name == "moonraker": IOLoop.current().spawn_callback(self.restart_service, name) + elif name in ALLOWED_SERVICES: + await self.restart_service(name) else: raise self.server.error( f"Invalid argument recevied for 'name': {name}")