15 个版本 (稳定版)

4.0.0 2024年2月16日
3.0.1 2023年5月12日
3.0.0 2022年9月13日
2.0.2 2022年5月10日
1.0.1 2020年7月19日

#177 in Unix APIs

Download history 23010/week @ 2024-04-23 21840/week @ 2024-04-30 18907/week @ 2024-05-07 22581/week @ 2024-05-14 26045/week @ 2024-05-21 29031/week @ 2024-05-28 25031/week @ 2024-06-04 20416/week @ 2024-06-11 20073/week @ 2024-06-18 24693/week @ 2024-06-25 20599/week @ 2024-07-02 20528/week @ 2024-07-09 23234/week @ 2024-07-16 27639/week @ 2024-07-23 18495/week @ 2024-07-30 20959/week @ 2024-08-06

96,358 monthly downloads

MIT 许可证

23KB
260 代码行数(不包括注释)

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.

状态:稳定。

示例代码

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(())
}

依赖项

~9–20MB
~292K SLoC