From 7511828552bbebd9757dd4ae8e6862309b911602 Mon Sep 17 00:00:00 2001 From: Neshura Date: Wed, 27 Dec 2023 20:55:51 +0100 Subject: [PATCH] Do not read dotfiles in zones.d directory --- src/config.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index cfdcbbf..2920855 100644 --- a/src/config.rs +++ b/src/config.rs @@ -92,7 +92,8 @@ impl ZoneConfig { let path = confy::get_configuration_file_path(env!("CARGO_PKG_NAME"), "interfaces").expect("Something went wrong with confy"); let zones_dir = path.parent().expect("Something went wrong with confy").join("zones.d/"); - let zones = fs::read_dir(zones_dir).unwrap(); + let zones = fs::read_dir(zones_dir).expect("Directory creation handling does not yet exist"); + let mut zone_configs: Vec = vec![]; @@ -106,7 +107,9 @@ impl ZoneConfig { false => eprintln!("[WARN] {warn_msg}"), } } - else { + else if !path.file_name().expect("Directories should have been filtered out by the leading if") + .to_str().expect("Conversion to str should not fail for a file name") + .starts_with('.') { let zone_config_path = format!("zones.d/{}", path.file_stem() .expect("stem could not be extracted from filename").to_str() .expect("&OsStr could not be converted to &str"));