zbus_polkit

Crates.iozbus_polkit
lib.rszbus_polkit
version5.0.0
sourcesrc
created_at2020-07-19 17:25:42.183202
updated_at2024-10-21 01:09:33.994328
descriptionPolicyKit binding
homepage
repositoryhttps://github.com/dbus2/zbus_polkit/
max_upload_size
id266929
size26,560
Zeeshan Ali Khan (zeenix)

documentation

README

zbus_polkit

CI Pipeline Status Documentation crates.io

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

use zbus::Connection;
use zbus_polkit::policykit1::*;

// Although we use `async-std` here, you can use any async runtime of choice.
#[async_std::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    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(())
}
Commit count: 194

cargo fmt