From ccbef4be871093f9c4e7d2e9aef0b652522fb597 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 4 Jun 2024 12:56:57 +0200 Subject: [PATCH] acme-api: use create_secret_dir from product-config Signed-off-by: Dietmar Maurer --- proxmox-acme-api/src/init.rs | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/proxmox-acme-api/src/init.rs b/proxmox-acme-api/src/init.rs index 32fa34b3..4869da29 100644 --- a/proxmox-acme-api/src/init.rs +++ b/proxmox-acme-api/src/init.rs @@ -2,8 +2,7 @@ use std::path::{Path, PathBuf}; use anyhow::Error; -use proxmox_sys::error::SysError; -use proxmox_sys::fs::CreateOptions; +use proxmox_product_config::create_secret_dir; struct AcmeApiConfig { acme_config_dir: PathBuf, @@ -24,8 +23,8 @@ pub fn init>(acme_config_dir: P, create_subdirs: bool) -> Result< } if create_subdirs { - create_secret_subdir(self::acme_config_dir())?; - create_secret_subdir(acme_account_dir())?; + create_secret_dir(self::acme_config_dir())?; + create_secret_dir(acme_account_dir())?; } Ok(()) @@ -53,17 +52,4 @@ pub(crate) fn plugin_cfg_filename() -> PathBuf { pub(crate) fn plugin_cfg_lockfile() -> PathBuf { acme_config_dir().join("plugins.lck") -} - -fn create_secret_subdir>(dir: P) -> nix::Result<()> { - let root_only = CreateOptions::new() - .owner(nix::unistd::ROOT) - .group(nix::unistd::Gid::from_raw(0)) - .perm(nix::sys::stat::Mode::from_bits_truncate(0o700)); - - match proxmox_sys::fs::create_dir(dir, root_only) { - Ok(()) => Ok(()), - Err(err) if err.already_exists() => Ok(()), - Err(err) => Err(err), - } -} +} \ No newline at end of file