🏁 Builds on Windows.

main
_ 2020-12-10 06:24:56 +00:00
parent 865bd1f01f
commit c4b12eb806
3 changed files with 21 additions and 5 deletions

View File

@ -109,12 +109,15 @@ async fn serve_file (
)
-> Result <Response, FileServerError>
{
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 ();

View File

@ -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 <Path> + 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 <Path> + Debug
> (
config_file_path: P
) -> Result <T, LoadTomlError> {
load_public (config_file_path)
}

View File

@ -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 (),