diff --git a/proxmox-acme-api/src/account_config.rs b/proxmox-acme-api/src/account_config.rs index 7c7bd8a3..834ab973 100644 --- a/proxmox-acme-api/src/account_config.rs +++ b/proxmox-acme-api/src/account_config.rs @@ -18,6 +18,7 @@ use proxmox_acme::types::AccountData as AcmeAccountData; use proxmox_acme::Account; use crate::types::AcmeAccountName; +use crate::acme_account_dir; #[inline] fn is_false(b: &bool) -> bool { @@ -78,10 +79,6 @@ impl AccountData { } } -fn acme_account_dir() -> PathBuf { - super::config::acme_config_dir().join("accounts") -} - /// Returns the path to the account configuration file (`$config_dir/accounts/$name`). pub fn account_cfg_filename(name: &str) -> PathBuf { acme_account_dir().join(name) @@ -96,7 +93,7 @@ pub(crate) fn foreach_acme_account(mut func: F) -> Result<(), Error> where F: FnMut(AcmeAccountName) -> ControlFlow>, { - match proxmox_sys::fs::scan_subdir(-1, acme_account_dir().as_path(), &SAFE_ID_REGEX) { + match proxmox_sys::fs::scan_subdir(-1, acme_account_dir(), &SAFE_ID_REGEX) { Ok(files) => { for file in files { let file = file?; diff --git a/proxmox-acme-api/src/config.rs b/proxmox-acme-api/src/config.rs index 02b2e68a..2f41fe5b 100644 --- a/proxmox-acme-api/src/config.rs +++ b/proxmox-acme-api/src/config.rs @@ -1,14 +1,13 @@ //! ACME API Configuration. use std::borrow::Cow; -use std::path::{Path, PathBuf}; +use std::path::Path; use proxmox_sys::error::SysError; use proxmox_sys::fs::CreateOptions; -use proxmox_product_config::product_config; - use crate::types::KnownAcmeDirectory; +use crate::acme_config_dir; /// List of known ACME directorties. pub const KNOWN_ACME_DIRECTORIES: &[KnownAcmeDirectory] = &[ @@ -25,17 +24,6 @@ pub const KNOWN_ACME_DIRECTORIES: &[KnownAcmeDirectory] = &[ /// Default ACME directorties. pub const DEFAULT_ACME_DIRECTORY_ENTRY: &KnownAcmeDirectory = &KNOWN_ACME_DIRECTORIES[0]; -pub(crate) fn acme_config_dir() -> PathBuf { - product_config().absolute_path("acme") -} - -pub(crate) fn plugin_cfg_filename() -> PathBuf { - acme_config_dir().join("plugins.cfg") -} - -pub(crate) fn plugin_cfg_lockfile() -> PathBuf { - acme_config_dir().join("plugins.lck") -} pub(crate) fn create_secret_subdir>(dir: P) -> nix::Result<()> { let root_only = CreateOptions::new() diff --git a/proxmox-acme-api/src/lib.rs b/proxmox-acme-api/src/lib.rs index 2bb2f6bd..ac1d8471 100644 --- a/proxmox-acme-api/src/lib.rs +++ b/proxmox-acme-api/src/lib.rs @@ -3,6 +3,11 @@ #[cfg(feature = "api-types")] pub mod types; +#[cfg(feature = "impl")] +mod init; +#[cfg(feature = "impl")] +pub use init::*; + #[cfg(feature = "impl")] mod config; diff --git a/proxmox-acme-api/src/plugin_config.rs b/proxmox-acme-api/src/plugin_config.rs index fa4d23db..f0e89f4e 100644 --- a/proxmox-acme-api/src/plugin_config.rs +++ b/proxmox-acme-api/src/plugin_config.rs @@ -56,19 +56,19 @@ fn init() -> SectionConfig { pub(crate) fn lock_plugin_config() -> Result { super::config::make_acme_dir()?; - let plugin_cfg_lockfile = super::config::plugin_cfg_lockfile(); + let plugin_cfg_lockfile = crate::plugin_cfg_lockfile(); open_api_lockfile(plugin_cfg_lockfile, None, true) } pub(crate) fn plugin_config() -> Result<(PluginData, ConfigDigest), Error> { - let plugin_cfg_filename = super::config::plugin_cfg_filename(); + let plugin_cfg_filename = crate::plugin_cfg_filename(); let content = proxmox_sys::fs::file_read_optional_string(&plugin_cfg_filename)?.unwrap_or_default(); let digest = ConfigDigest::from_slice(content.as_bytes()); - let mut data = CONFIG.parse(&plugin_cfg_filename, &content)?; + let mut data = CONFIG.parse(plugin_cfg_filename, &content)?; if data.sections.get("standalone").is_none() { let standalone = StandalonePlugin::default(); @@ -81,7 +81,7 @@ pub(crate) fn plugin_config() -> Result<(PluginData, ConfigDigest), Error> { pub(crate) fn save_plugin_config(config: &PluginData) -> Result<(), Error> { super::config::make_acme_dir()?; - let plugin_cfg_filename = super::config::plugin_cfg_filename(); + let plugin_cfg_filename = crate::plugin_cfg_filename(); let raw = CONFIG.write(&plugin_cfg_filename, &config.data)?; replace_config(plugin_cfg_filename, raw.as_bytes())