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