Skip to content

Commit 2eee564

Browse files
committed
windows: Build without uzers
Instead of including windows dependencies, just check if it works and report an error. If the driver is not available for that platform. The error message from framework_lib will say that. That's why I also print that. Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 314609f commit 2eee564

2 files changed

Lines changed: 25 additions & 9 deletions

File tree

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ smbios-lib = { git = "https://github.com/FrameworkComputer/smbios-lib.git", bran
1616
color-eyre = "0.6.5"
1717
tokio = { version = "1.47.1", features = ["full"] }
1818
futures = "0.3.31"
19-
uzers = { version = "0.12.1", default-features = false }
2019
tui-popup = "0.6.0"
20+
21+
[target.'cfg(unix)'.dependencies]
22+
uzers = { version = "0.12.1", default-features = false }

src/main.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
use framework_tool_tui::app::App;
2+
#[cfg(unix)]
23
use uzers::get_current_uid;
34

45
#[tokio::main]
56
async fn main() -> color_eyre::Result<()> {
67
color_eyre::install()?;
78

8-
if !check_permissions() {
9-
return Err(color_eyre::Report::msg(
10-
"The application needs to be run with root privileges.",
11-
));
12-
}
9+
check_permissions()?;
1310

1411
let mut terminal = ratatui::init();
1512
let mut app = App::new()?;
@@ -21,9 +18,26 @@ async fn main() -> color_eyre::Result<()> {
2118
result
2219
}
2320

24-
fn check_permissions() -> bool {
25-
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
21+
#[cfg(unix)]
22+
fn check_permissions() -> color_eyre::Result<()> {
2623
let is_admin = get_current_uid() == 0;
2724

28-
is_admin
25+
if !is_admin {
26+
return Err(color_eyre::Report::msg(
27+
"The application needs to be run with root privileges.",
28+
));
29+
}
30+
31+
Ok(())
32+
}
33+
34+
#[cfg(windows)]
35+
fn check_permissions() -> color_eyre::Result<()> {
36+
if let Err(err) = framework_lib::chromium_ec::CrosEc::new().version_info() {
37+
return Err(color_eyre::Report::msg(
38+
format!("The application needs to be run as admin: {:?}.", err),
39+
));
40+
}
41+
42+
Ok(())
2943
}

0 commit comments

Comments
 (0)