diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f50193..347400c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - An invalid reference in the command line arguments has been fixed. +- Some missing file path in log messages has been added. ## [0.19.0] - 2022-04-17 diff --git a/acmed/src/config.rs b/acmed/src/config.rs index 8ed0e05..2e3d134 100644 --- a/acmed/src/config.rs +++ b/acmed/src/config.rs @@ -682,7 +682,9 @@ fn get_cnf_path(from: &Path, file: &str) -> Result, Error> { } fn read_cnf(path: &Path, loaded_files: &mut BTreeSet) -> Result { - let path = path.canonicalize()?; + let path = path + .canonicalize() + .map_err(|e| Error::from(e).prefix(&path.display().to_string()))?; if loaded_files.contains(&path) { info!("{}: configuration file already loaded", path.display()); return Ok(Config::default()); diff --git a/acmed/src/hooks.rs b/acmed/src/hooks.rs index 483b27f..f42df9c 100644 --- a/acmed/src/hooks.rs +++ b/acmed/src/hooks.rs @@ -176,7 +176,7 @@ where hook.name, &file_name )); let stdin = cmd.stdin.as_mut().ok_or("stdin not found")?; - let file = File::open(&file_name)?; + let file = File::open(&file_name).map_err(|e| Error::from(e).prefix(&file_name))?; let buf_reader = BufReader::new(file); for line in buf_reader.lines() { let line = format!("{}\n", line?); diff --git a/acmed/src/http.rs b/acmed/src/http.rs index 62f07b3..14a8274 100644 --- a/acmed/src/http.rs +++ b/acmed/src/http.rs @@ -162,7 +162,9 @@ fn get_session(root_certs: &[String]) -> Result { #[cfg(feature = "crypto_openssl")] { let mut buff = Vec::new(); - File::open(crt_file)?.read_to_end(&mut buff)?; + File::open(crt_file) + .map_err(|e| Error::from(e).prefix(crt_file))? + .read_to_end(&mut buff)?; let crt = X509Certificate::from_pem_native(&buff)?; session.add_root_certificate(crt); } diff --git a/acmed/src/storage.rs b/acmed/src/storage.rs index 712c73f..5f71a1f 100644 --- a/acmed/src/storage.rs +++ b/acmed/src/storage.rs @@ -125,7 +125,8 @@ fn get_file_path(fm: &FileManager, file_type: FileType) -> Result Result, Error> { fm.trace(&format!("reading file {:?}", path)); - let mut file = File::open(path)?; + let mut file = + File::open(path).map_err(|e| Error::from(e).prefix(&path.display().to_string()))?; let mut contents = vec![]; file.read_to_end(&mut contents)?; Ok(contents) @@ -210,13 +211,18 @@ fn write_file(fm: &FileManager, file_type: FileType, data: &[u8]) -> Result<(), FileType::PrivateKey => fm.pk_file_mode, FileType::Account => crate::DEFAULT_ACCOUNT_FILE_MODE, }); - options.write(true).create(true).open(&path)? + options + .write(true) + .create(true) + .open(&path) + .map_err(|e| Error::from(e).prefix(&path.display().to_string()))? } else { - File::create(&path)? + File::create(&path).map_err(|e| Error::from(e).prefix(&path.display().to_string()))? }; - file.write_all(data)?; + file.write_all(data) + .map_err(|e| Error::from(e).prefix(&path.display().to_string()))?; if cfg!(unix) { - set_owner(fm, &path, file_type)?; + set_owner(fm, &path, file_type).map_err(|e| e.prefix(&path.display().to_string()))?; } if is_new {