15 releases (stable)

4.0.0 Feb 16, 2024
3.0.1 May 12, 2023
3.0.0 Sep 13, 2022
2.0.2 May 10, 2022
1.0.1 Jul 19, 2020

#143 in Unix APIs

Download history 15517/week @ 2024-01-24 16709/week @ 2024-01-31 16201/week @ 2024-02-07 18161/week @ 2024-02-14 24961/week @ 2024-02-21 23118/week @ 2024-02-28 25669/week @ 2024-03-06 17707/week @ 2024-03-13 26657/week @ 2024-03-20 22071/week @ 2024-03-27 20267/week @ 2024-04-03 13516/week @ 2024-04-10 22478/week @ 2024-04-17 22234/week @ 2024-04-24 22822/week @ 2024-05-01 13476/week @ 2024-05-08

85,967 downloads per month

MIT license

23KB
260 lines

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

~9–20MB
~292K SLoC