machine: add endpoint to check sudo access
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
59403e226b
commit
272f7b946d
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue