diff --git a/acmed/src/config.rs b/acmed/src/config.rs index 8b1145a..036cef2 100644 --- a/acmed/src/config.rs +++ b/acmed/src/config.rs @@ -662,8 +662,8 @@ fn init_directories(config: &Config) -> Result<(), Error> { Ok(()) } -fn get_cnf_path(from: &PathBuf, file: &str) -> Result, Error> { - let mut path = from.clone().canonicalize()?; +fn get_cnf_path(from: &Path, file: &str) -> Result, Error> { + let mut path = from.to_path_buf().canonicalize()?; path.pop(); path.push(file); let err = format!("{:?}: invalid UTF-8 path", path); @@ -681,14 +681,14 @@ fn get_cnf_path(from: &PathBuf, file: &str) -> Result, Error> { Ok(g) } -fn read_cnf(path: &PathBuf, loaded_files: &mut BTreeSet) -> Result { +fn read_cnf(path: &Path, loaded_files: &mut BTreeSet) -> Result { let path = path.canonicalize()?; if loaded_files.contains(&path) { info!("{}: configuration file already loaded", path.display()); return Ok(Config::default()); } loaded_files.insert(path.clone()); - info!("{}: loading configuration file", path.display()); + info!("{}: loading configuration file", &path.display()); let mut file = File::open(&path).map_err(|e| Error::from(e).prefix(&path.display().to_string()))?; let mut contents = String::new(); diff --git a/acmed/src/storage.rs b/acmed/src/storage.rs index bc7930f..6f17005 100644 --- a/acmed/src/storage.rs +++ b/acmed/src/storage.rs @@ -9,7 +9,7 @@ use std::collections::HashMap; use std::fmt; use std::fs::{File, OpenOptions}; use std::io::{Read, Write}; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; #[cfg(target_family = "unix")] use std::os::unix::fs::OpenOptionsExt; @@ -123,7 +123,7 @@ fn get_file_path(fm: &FileManager, file_type: FileType) -> Result Result, Error> { +fn read_file(fm: &FileManager, path: &Path) -> Result, Error> { fm.trace(&format!("reading file {:?}", path)); let mut file = File::open(path)?; let mut contents = vec![]; @@ -132,7 +132,7 @@ fn read_file(fm: &FileManager, path: &PathBuf) -> Result, Error> { } #[cfg(unix)] -fn set_owner(fm: &FileManager, path: &PathBuf, file_type: FileType) -> Result<(), Error> { +fn set_owner(fm: &FileManager, path: &Path, file_type: FileType) -> Result<(), Error> { let (uid, gid) = match file_type { FileType::Certificate => (fm.cert_file_owner.to_owned(), fm.cert_file_group.to_owned()), FileType::PrivateKey => (fm.pk_file_owner.to_owned(), fm.pk_file_group.to_owned()),