From 6827a5c02cdd92848d7e13f247db3e9e92b5677d Mon Sep 17 00:00:00 2001 From: autoantohaki Date: Wed, 21 Oct 2026 16:04:50 -0300 Subject: [PATCH] Fix Linux build: convert rustix errors and satisfy clippy The Unix-only model store used ? on rustix calls whose Errno had no conversion into the crate error, so cargo check failed on Linux and CI on main has been red since. Add the conversion, and take the credential open error by reference so the Unix branch of map_open_error passes clippy without an underscore-prefixed binding. --- crates/impossible-models/src/lib.rs | 7 +++++++ crates/impossible-server-core/src/security.rs | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/impossible-models/src/lib.rs b/crates/impossible-models/src/lib.rs index 69b2f72..57ffbdb 100644 --- a/crates/impossible-models/src/lib.rs +++ b/crates/impossible-models/src/lib.rs @@ -151,6 +151,13 @@ impl From for Error { } } +#[cfg(unix)] +impl From for Error { + fn from(value: rustix::io::Errno) -> Self { + Self::Io(value.into()) + } +} + impl From for Error { fn from(value: reqwest::Error) -> Self { let kind = if value.is_connect() { diff --git a/crates/impossible-server-core/src/security.rs b/crates/impossible-server-core/src/security.rs index b25df83..c8ade72 100644 --- a/crates/impossible-server-core/src/security.rs +++ b/crates/impossible-server-core/src/security.rs @@ -109,7 +109,7 @@ fn open_secret_file(path: &Path) -> Result { let mut options = OpenOptions::new(); options.read(true); configure_no_follow(&mut options); - options.open(path).map_err(map_open_error) + options.open(path).map_err(|error| map_open_error(&error)) } #[cfg(unix)] @@ -136,9 +136,10 @@ fn configure_no_follow(options: &mut OpenOptions) { #[cfg(not(any(unix, windows)))] fn configure_no_follow(_options: &mut OpenOptions) {} -fn map_open_error(_error: std::io::Error) -> CredentialError { +#[cfg_attr(not(unix), allow(unused_variables))] +fn map_open_error(error: &std::io::Error) -> CredentialError { #[cfg(unix)] - if _error.raw_os_error() == Some(libc::ELOOP) { + if error.raw_os_error() == Some(libc::ELOOP) { return CredentialError::Invalid; } CredentialError::Unavailable