11 releases (6 stable)

new 2.0.1 Jan 12, 2022
2.0.0-beta.8 Dec 27, 2021
2.0.0-beta.7 Sep 29, 2021
2.0.0-beta.6 Jul 30, 2021
1.0.1 Jul 19, 2020

#163 in Unix APIs

Download history 6286/week @ 2021-09-28 4673/week @ 2021-10-05 6542/week @ 2021-10-12 7779/week @ 2021-10-19 6126/week @ 2021-10-26 6892/week @ 2021-11-02 8269/week @ 2021-11-09 9908/week @ 2021-11-16 6263/week @ 2021-11-23 8598/week @ 2021-11-30 9541/week @ 2021-12-07 9131/week @ 2021-12-14 3444/week @ 2021-12-21 1134/week @ 2021-12-28 7025/week @ 2022-01-04 8772/week @ 2022-01-11

21,551 downloads per month

MIT license

730KB
16K SLoC

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

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(())
}

Dependencies

~6.5MB
~136K SLoC