dbus: Add NameOwners helper

This monitors `NameOwnerChanged` events to keep track of what unique
names own what well-known names on the bus. This allows dbus protocol
implementations to check that callers own a certain name.

To initially populate the list of dbus name owners, `ListNames` is used
at start. Then `GetNameOwner` is lazily invoked to populate owners that
exist at start. To avoid calling that for every single name on the bus.

This also keeps track of unique bus names, which don't require any
additional methods or signals to monitor. This allows us to also detect
if a client has disappeared from the bus.

The `COSMIC_ENFORCE_DBUS_OWNERS` allows disabling checking of owned
names.
This commit is contained in:
Ian Douglas Scott 2025-06-20 14:39:59 -07:00 committed by Ian Douglas Scott
parent 55401b1e53
commit d08ac9645b
2 changed files with 203 additions and 0 deletions

View file

@ -13,6 +13,7 @@ use zbus::blocking::{Connection, fdo::DBusProxy};
#[cfg(feature = "systemd")]
pub mod logind;
mod name_owners;
mod power;
pub fn init(