Do not read dotfiles in zones.d directory

This commit is contained in:
Neshura 2023-12-27 20:55:51 +01:00
parent 50d179cbd3
commit a36411416c
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C

View file

@ -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 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_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<Self> = vec![]; let mut zone_configs: Vec<Self> = vec![];
@ -106,7 +107,9 @@ impl ZoneConfig {
false => eprintln!("[WARN] {warn_msg}"), 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() let zone_config_path = format!("zones.d/{}", path.file_stem()
.expect("stem could not be extracted from filename").to_str() .expect("stem could not be extracted from filename").to_str()
.expect("&OsStr could not be converted to &str")); .expect("&OsStr could not be converted to &str"));