add helpers to write configuration files
This commit is contained in:
committed by
Thomas Lamprecht
parent
7526d86419
commit
a301c362e3
@ -9,8 +9,6 @@ use proxmox::api::{
|
||||
section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin},
|
||||
};
|
||||
|
||||
use proxmox::tools::{fs::replace_file, fs::CreateOptions};
|
||||
|
||||
use crate::api2::types::PROXMOX_SAFE_ID_FORMAT;
|
||||
use crate::backup::{open_backup_lockfile, BackupLockGuard};
|
||||
|
||||
@ -168,19 +166,7 @@ pub fn config() -> Result<(PluginData, [u8; 32]), Error> {
|
||||
pub fn save_config(config: &PluginData) -> Result<(), Error> {
|
||||
super::make_acme_dir()?;
|
||||
let raw = CONFIG.write(ACME_PLUGIN_CFG_FILENAME, &config.data)?;
|
||||
|
||||
let backup_user = crate::backup::backup_user()?;
|
||||
let mode = nix::sys::stat::Mode::from_bits_truncate(0o0640);
|
||||
// set the correct owner/group/permissions while saving file
|
||||
// owner(rw) = root, group(r)= backup
|
||||
let options = CreateOptions::new()
|
||||
.perm(mode)
|
||||
.owner(nix::unistd::ROOT)
|
||||
.group(backup_user.gid);
|
||||
|
||||
replace_file(ACME_PLUGIN_CFG_FILENAME, raw.as_bytes(), options)?;
|
||||
|
||||
Ok(())
|
||||
crate::backup::replace_backup_config(ACME_PLUGIN_CFG_FILENAME, raw.as_bytes())
|
||||
}
|
||||
|
||||
pub struct PluginData {
|
||||
|
Reference in New Issue
Block a user