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 <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2021-05-31 07:34:16 -04:00
parent 0ab9ffdc93
commit def6b365fa
1 changed files with 5 additions and 2 deletions

View File

@ -107,7 +107,7 @@ class Machine:
f'sudo systemctl {action} {service_name}') f'sudo systemctl {action} {service_name}')
async def _handle_service_request(self, web_request: WebRequest) -> str: 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] action = web_request.get_endpoint().split('/')[-1]
if name == "moonraker": if name == "moonraker":
if action != "restart": if action != "restart":
@ -118,8 +118,11 @@ class Machine:
elif name in self.available_services: elif name in self.available_services:
await self.do_service_action(action, name) await self.do_service_action(action, name)
else: 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( raise self.server.error(
f"Invalid argument recevied for 'name': {name}") f"Service '{name}' not allowed")
return "ok" return "ok"
async def _handle_sysinfo_request(self, async def _handle_sysinfo_request(self,