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

#120 in Unix APIs

Download history 20978/week @ 2024-11-30 19736/week @ 2024-12-07 20442/week @ 2024-12-14 3475/week @ 2024-12-21 5814/week @ 2024-12-28 21102/week @ 2025-01-04 30395/week @ 2025-01-11 20901/week @ 2025-01-18 27817/week @ 2025-01-25 30247/week @ 2025-02-01 31383/week @ 2025-02-08 24177/week @ 2025-02-15 29565/week @ 2025-02-22 27307/week @ 2025-03-01 29719/week @ 2025-03-08 25198/week @ 2025-03-15

117,003 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
~315K SLoC