15 releases (stable)

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

#83 in Unix APIs

Download history 17835/week @ 2024-03-14 26928/week @ 2024-03-21 23593/week @ 2024-03-28 15360/week @ 2024-04-04 16620/week @ 2024-04-11 22766/week @ 2024-04-18 22292/week @ 2024-04-25 22711/week @ 2024-05-02 17003/week @ 2024-05-09 26038/week @ 2024-05-16 25600/week @ 2024-05-23 30012/week @ 2024-05-30 19779/week @ 2024-06-06 20745/week @ 2024-06-13 23650/week @ 2024-06-20 18355/week @ 2024-06-27

89,443 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

~9–20MB
~293K SLoC