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

#85 in Unix APIs

Download history 15494/week @ 2024-08-01 17775/week @ 2024-08-08 16015/week @ 2024-08-15 17200/week @ 2024-08-22 16614/week @ 2024-08-29 20063/week @ 2024-09-05 15194/week @ 2024-09-12 18747/week @ 2024-09-19 17928/week @ 2024-09-26 19389/week @ 2024-10-03 18099/week @ 2024-10-10 24275/week @ 2024-10-17 24415/week @ 2024-10-24 22148/week @ 2024-10-31 26709/week @ 2024-11-07 24581/week @ 2024-11-14

103,010 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–20MB
~298K SLoC