machine: add endpoint to check sudo access

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-08-21 05:59:04 -04:00
parent 59403e226b
commit 272f7b946d
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 8 additions and 0 deletions

View File

@ -113,6 +113,8 @@ class Machine:
self.server.register_endpoint(
"/machine/system_info", ['GET'],
self._handle_sysinfo_request)
self.server.register_endpoint(
"/machine/sudo", ["GET"], self._handle_sudo_check)
self.server.register_endpoint(
"/machine/sudo/password", ["POST"],
self._set_sudo_password)
@ -239,6 +241,12 @@ class Machine:
self.server.send_event("machine:sudo_password_set")
return "ok"
async def _handle_sudo_check(
self, web_request: WebRequest
) -> Dict[str, Any]:
has_sudo = await self.check_sudo_access()
return {"sudo_access": has_sudo}
def get_system_info(self) -> Dict[str, Any]:
return self.system_info