diff --git a/crates/ptth_server/src/file_server/internal.rs b/crates/ptth_server/src/file_server/internal.rs index 07ddb81..695c0b3 100644 --- a/crates/ptth_server/src/file_server/internal.rs +++ b/crates/ptth_server/src/file_server/internal.rs @@ -109,12 +109,15 @@ async fn serve_file ( ) -> Result { - use std::os::unix::fs::PermissionsExt; - let file_md = file.metadata ().await.map_err (FileServerError::CantGetFileMetadata)?; - if file_md.permissions ().mode () == load_toml::CONFIG_PERMISSIONS_MODE + + #[cfg (unix)] { - return Ok (Response::Forbidden); + use std::os::unix::fs::PermissionsExt; + if file_md.permissions ().mode () == load_toml::CONFIG_PERMISSIONS_MODE + { + return Ok (Response::Forbidden); + } } let file_len = file_md.len (); diff --git a/crates/ptth_server/src/load_toml.rs b/crates/ptth_server/src/load_toml.rs index f92b73d..6851467 100644 --- a/crates/ptth_server/src/load_toml.rs +++ b/crates/ptth_server/src/load_toml.rs @@ -39,6 +39,7 @@ pub fn load_public < /// For files that may contain secrets and should have permissions or other /// safeties checked +#[cfg (unix)] pub fn load < T: DeserializeOwned, P: AsRef + Debug @@ -56,3 +57,15 @@ pub fn load < load_inner (f) } + +// The permission check doesn't work on Windows + +#[cfg (not (unix))] +pub fn load < + T: DeserializeOwned, + P: AsRef + Debug +> ( + config_file_path: P +) -> Result { + load_public (config_file_path) +} diff --git a/src/tests.rs b/src/tests.rs index 3b8a6cf..a0eb534 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -69,7 +69,7 @@ fn end_to_end () { }) }; - delay_for (Duration::from_millis (500)).await; + delay_for (Duration::from_millis (1000)).await; assert_eq! (relay_state.list_servers ().await, vec! [ server_name.to_string (),