From 566d09a618a94db2c0aad3910914aacc0236c2a4 Mon Sep 17 00:00:00 2001 From: Rodolphe Breard Date: Tue, 25 Aug 2020 20:27:17 +0200 Subject: [PATCH] Warn on empty inclusion patterns --- acmed/src/config.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/acmed/src/config.rs b/acmed/src/config.rs index daa23a6..f55a158 100644 --- a/acmed/src/config.rs +++ b/acmed/src/config.rs @@ -459,12 +459,22 @@ fn init_directories(config: &Config) -> Result<(), Error> { } fn get_cnf_path(from: &PathBuf, file: &str) -> Result, Error> { - let mut path = from.clone(); + let mut path = from.clone().canonicalize()?; path.pop(); path.push(file); let err = format!("{:?}: invalid UTF-8 path", path); let raw_path = path.to_str().ok_or(err)?; - Ok(glob(raw_path)?.filter_map(Result::ok).collect()) + let g = glob(raw_path)? + .filter_map(Result::ok) + .collect::>(); + if g.is_empty() { + log::warn!( + "Pattern `{}` (expanded as `{}`): no matching configuration file found.", + file, + raw_path + ); + } + Ok(g) } fn read_cnf(path: &PathBuf) -> Result {