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

#94 in Unix APIs

Download history 25255/week @ 2024-10-22 20339/week @ 2024-10-29 27036/week @ 2024-11-05 29224/week @ 2024-11-12 22886/week @ 2024-11-19 11735/week @ 2024-11-26 22610/week @ 2024-12-03 18283/week @ 2024-12-10 18897/week @ 2024-12-17 3211/week @ 2024-12-24 8969/week @ 2024-12-31 22477/week @ 2025-01-07 27760/week @ 2025-01-14 24189/week @ 2025-01-21 26344/week @ 2025-01-28 26759/week @ 2025-02-04

109,864 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

~8–19MB
~296K SLoC