Browse Source

Add some missing file path in log messages

Rel #24
pull/62/head
Rodolphe Bréard 3 years ago
parent
commit
01894bcf27
  1. 1
      CHANGELOG.md
  2. 4
      acmed/src/config.rs
  3. 2
      acmed/src/hooks.rs
  4. 4
      acmed/src/http.rs
  5. 16
      acmed/src/storage.rs

1
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

4
acmed/src/config.rs

@ -682,7 +682,9 @@ fn get_cnf_path(from: &Path, file: &str) -> Result<Vec<PathBuf>, Error> {
}
fn read_cnf(path: &Path, loaded_files: &mut BTreeSet<PathBuf>) -> Result<Config, Error> {
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());

2
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?);

4
acmed/src/http.rs

@ -162,7 +162,9 @@ fn get_session(root_certs: &[String]) -> Result<Session, Error> {
#[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);
}

16
acmed/src/storage.rs

@ -125,7 +125,8 @@ fn get_file_path(fm: &FileManager, file_type: FileType) -> Result<PathBuf, Error
fn read_file(fm: &FileManager, path: &Path) -> Result<Vec<u8>, 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 {

Loading…
Cancel
Save