16 releases (stable)

5.0.0 Oct 21, 2024
4.0.0 Feb 16, 2024
3.0.1 May 12, 2023
3.0.0 Sep 13, 2022
1.0.1 Jul 19, 2020

#91 in Unix APIs

Download history 16527/week @ 2024-08-18 19165/week @ 2024-08-25 16904/week @ 2024-09-01 16723/week @ 2024-09-08 16539/week @ 2024-09-15 21060/week @ 2024-09-22 15538/week @ 2024-09-29 20780/week @ 2024-10-06 20502/week @ 2024-10-13 24750/week @ 2024-10-20 19545/week @ 2024-10-27 27870/week @ 2024-11-03 28015/week @ 2024-11-10 25046/week @ 2024-11-17 12422/week @ 2024-11-24 21204/week @ 2024-12-01

86,892 downloads per month

MIT license

24KB
263 lines

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

Dependencies

~9–19MB
~296K SLoC