15 releases (stable)

new 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

#579 in Unix APIs

Download history 16074/week @ 2023-10-27 15439/week @ 2023-11-03 22544/week @ 2023-11-10 21494/week @ 2023-11-17 12925/week @ 2023-11-24 14830/week @ 2023-12-01 12777/week @ 2023-12-08 9597/week @ 2023-12-15 2551/week @ 2023-12-22 8564/week @ 2023-12-29 13675/week @ 2024-01-05 14061/week @ 2024-01-12 17457/week @ 2024-01-19 18310/week @ 2024-01-26 12104/week @ 2024-02-02 18125/week @ 2024-02-09

68,955 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

~12–26MB
~373K SLoC