https://github.com/dbus2/zbus_polkit
PolicyKit zbus proxy
https://github.com/dbus2/zbus_polkit
policykit security unix zbus
Last synced: about 1 month ago
JSON representation
PolicyKit zbus proxy
- Host: GitHub
- URL: https://github.com/dbus2/zbus_polkit
- Owner: dbus2
- License: mit
- Created: 2023-07-29T21:18:45.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-06T15:22:21.000Z (about 1 month ago)
- Last Synced: 2025-04-12T16:17:49.113Z (about 1 month ago)
- Topics: policykit, security, unix, zbus
- Language: Rust
- Homepage:
- Size: 231 KB
- Stars: 8
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zbus_polkit
[](https://github.com/dbus2/zbus/actions/workflows/rust.yml)
[](https://docs.rs/zbus_polkit/)
[](https://crates.io/crates/zbus_polkit)A crate to interact with [PolicyKit], a toolkit for defining and handling authorizations. It is used
for allowing unprivileged processes to speak to privileged processes.**Status:** Stable.
## Example code
```rust,no_run
use zbus::Connection;
use zbus_polkit::policykit1::*;// Although we use `tokio` here, you can use any async runtime of choice.
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box> {
let connection = Connection::system().await?;
let proxy = AuthorityProxy::new(&connection).await?;
let subject = Subject::new_for_owner(std::process::id(), None, None)?;
let result = proxy.check_authorization(
&subject,
"org.zbus.BeAwesome",
&std::collections::HashMap::new(),
CheckAuthorizationFlags::AllowUserInteraction.into(),
"",
).await?;Ok(())
}
```[PolicyKit]: https://gitlab.freedesktop.org/polkit/polkit/