From def6b365facc7eab364c823d5b5a244aa682204a Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Mon, 31 May 2021 07:34:16 -0400 Subject: [PATCH] machine: fix service case sensitivity bug Systemd units are case sensitive, do not convert the "name" argument for service requests to lower case. Signed-off-by: Eric Callahan --- moonraker/components/machine.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/moonraker/components/machine.py b/moonraker/components/machine.py index 8430d79..9ac4cbd 100644 --- a/moonraker/components/machine.py +++ b/moonraker/components/machine.py @@ -107,7 +107,7 @@ class Machine: f'sudo systemctl {action} {service_name}') async def _handle_service_request(self, web_request: WebRequest) -> str: - name: str = web_request.get('service').lower() + name: str = web_request.get('service') action = web_request.get_endpoint().split('/')[-1] if name == "moonraker": if action != "restart": @@ -118,8 +118,11 @@ class Machine: elif name in self.available_services: await self.do_service_action(action, name) else: + if name in ALLOWED_SERVICES and \ + name not in self.available_services: + raise self.server.error(f"Service '{name}' not installed") raise self.server.error( - f"Invalid argument recevied for 'name': {name}") + f"Service '{name}' not allowed") return "ok" async def _handle_sysinfo_request(self,