dbus_manager: fix polkit warning

Only warn that polkit is unavailable when a component attempts
to use it to check a permission.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2023-06-19 19:29:02 -04:00
parent a797dd0b50
commit 3b62ed4e4f
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 6 additions and 3 deletions

View File

@ -67,15 +67,18 @@ class DbusManager:
"/org/freedesktop/PolicyKit1/Authority",
"org.freedesktop.PolicyKit1.Authority")
except self.DbusError:
self.server.add_warning(
"Unable to find DBus PolKit Interface, this suggests PolKit "
"is not installed on your OS.")
self.polkit = None
async def check_permission(self,
action: str,
err_msg: str = ""
) -> bool:
if self.polkit is None:
self.server.add_warning(
"Unable to find DBus PolKit Interface, this suggests PolKit "
"is not installed on your OS.",
"dbus_polkit"
)
return False
try:
ret = await self.polkit.call_check_authorization( # type: ignore