Skip to content

Commit 601c6e6

Browse files
committed
fix(polkit): check feature flag before creating new dbus connection
1 parent 19e7263 commit 601c6e6

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/dbus/polkit.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
use zbus::{fdo, message::Header, Connection};
1+
use std::collections::HashMap;
2+
use zbus::zvariant::{OwnedValue, Value};
3+
use zbus::{fdo, message::Header, Connection, Proxy};
24

35
pub async fn check_polkit(hdr: Option<Header<'_>>, action_id: &str) -> fdo::Result<()> {
6+
if !cfg!(feature = "polkit") {
7+
return Ok(());
8+
}
49
let connection = Connection::system()
510
.await
611
.map_err(|e| fdo::Error::Failed(format!("Failed to acquire dbus connection: {e}")))?;
712
check_polkit_with_connection(hdr, action_id, connection).await
813
}
914

10-
#[cfg(feature = "polkit")]
1115
pub async fn check_polkit_with_connection(
1216
hdr: Option<Header<'_>>,
1317
action_id: &str,
@@ -87,12 +91,3 @@ pub async fn check_polkit_with_connection(
8791
)))
8892
}
8993
}
90-
91-
#[cfg(not(feature = "polkit"))]
92-
pub async fn check_polkit_with_connection(
93-
_hdr: Option<Header<'_>>,
94-
_action_id: &str,
95-
_connection: Connection,
96-
) -> fdo::Result<()> {
97-
Ok(())
98-
}

0 commit comments

Comments
 (0)