dbus_manager: handle all PolKit interface errors
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
a7e154fbe4
commit
8eddec88cb
|
@ -5,6 +5,7 @@
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import os
|
import os
|
||||||
|
import asyncio
|
||||||
import pathlib
|
import pathlib
|
||||||
import logging
|
import logging
|
||||||
import dbus_next
|
import dbus_next
|
||||||
|
@ -57,6 +58,8 @@ class DbusManager:
|
||||||
try:
|
try:
|
||||||
self.bus = MessageBus(bus_type=BusType.SYSTEM)
|
self.bus = MessageBus(bus_type=BusType.SYSTEM)
|
||||||
await self.bus.connect()
|
await self.bus.connect()
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
raise
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.info("Unable to Connect to D-Bus")
|
logging.info("Unable to Connect to D-Bus")
|
||||||
return
|
return
|
||||||
|
@ -66,7 +69,13 @@ class DbusManager:
|
||||||
"org.freedesktop.PolicyKit1",
|
"org.freedesktop.PolicyKit1",
|
||||||
"/org/freedesktop/PolicyKit1/Authority",
|
"/org/freedesktop/PolicyKit1/Authority",
|
||||||
"org.freedesktop.PolicyKit1.Authority")
|
"org.freedesktop.PolicyKit1.Authority")
|
||||||
except self.DbusError:
|
except asyncio.CancelledError:
|
||||||
|
raise
|
||||||
|
except Exception as e:
|
||||||
|
if self.server.is_debug_enabled():
|
||||||
|
logging.exception("Failed to get PolKit interface")
|
||||||
|
else:
|
||||||
|
logging.info(f"Failed to get PolKit interface: {e}")
|
||||||
self.polkit = None
|
self.polkit = None
|
||||||
|
|
||||||
async def check_permission(self,
|
async def check_permission(self,
|
||||||
|
@ -83,6 +92,8 @@ class DbusManager:
|
||||||
try:
|
try:
|
||||||
ret = await self.polkit.call_check_authorization( # type: ignore
|
ret = await self.polkit.call_check_authorization( # type: ignore
|
||||||
self.polkit_subject, action, {}, 0, "")
|
self.polkit_subject, action, {}, 0, "")
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._check_warned()
|
self._check_warned()
|
||||||
self.server.add_warning(
|
self.server.add_warning(
|
||||||
|
|
Loading…
Reference in New Issue