cleanup User configuration: use Updater
This commit is contained in:
@ -9,10 +9,9 @@ use lazy_static::lazy_static;
|
||||
use proxmox::api::UserInformation;
|
||||
use proxmox::tools::time::epoch_i64;
|
||||
|
||||
use pbs_api_types::{Authid, Userid, ROLE_ADMIN};
|
||||
use pbs_api_types::{Authid, Userid, User, ApiToken, ROLE_ADMIN};
|
||||
use pbs_config::acl::{AclTree, ROLE_NAMES};
|
||||
|
||||
use super::user::{ApiToken, User};
|
||||
use crate::tools::Memcom;
|
||||
|
||||
/// Cache User/Group/Token/Acl configuration data for fast permission tests
|
||||
|
@ -27,8 +27,7 @@ use proxmox::tools::AsHex;
|
||||
|
||||
use pbs_buildcfg::configdir;
|
||||
use pbs_config::{open_backup_lockfile, BackupLockGuard};
|
||||
|
||||
use crate::api2::types::Userid;
|
||||
use pbs_api_types::{Userid, User};
|
||||
|
||||
/// Mapping of userid to TFA entry.
|
||||
pub type TfaUsers = HashMap<Userid, TfaUserData>;
|
||||
@ -278,7 +277,6 @@ impl TfaConfig {
|
||||
|
||||
/// Remove non-existent users.
|
||||
pub fn cleanup_users(&mut self, config: &proxmox::api::section_config::SectionConfigData) {
|
||||
use crate::config::user::User;
|
||||
self.users
|
||||
.retain(|user, _| config.lookup::<User>("user", user.as_str()).is_ok());
|
||||
}
|
||||
|
@ -13,11 +13,10 @@ use proxmox::api::{
|
||||
}
|
||||
};
|
||||
|
||||
use pbs_api_types::{Authid, Userid};
|
||||
pub use pbs_api_types::{ApiToken, User};
|
||||
pub use pbs_api_types::{
|
||||
EMAIL_SCHEMA, ENABLE_USER_SCHEMA, EXPIRE_USER_SCHEMA, FIRST_NAME_SCHEMA, LAST_NAME_SCHEMA,
|
||||
use pbs_api_types::{
|
||||
Authid, Userid, ApiToken, User,
|
||||
};
|
||||
use pbs_config::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
|
||||
|
||||
use crate::tools::Memcom;
|
||||
|
||||
@ -48,6 +47,11 @@ fn init() -> SectionConfig {
|
||||
pub const USER_CFG_FILENAME: &str = "/etc/proxmox-backup/user.cfg";
|
||||
pub const USER_CFG_LOCKFILE: &str = "/etc/proxmox-backup/.user.lck";
|
||||
|
||||
/// Get exclusive lock
|
||||
pub fn lock_config() -> Result<BackupLockGuard, Error> {
|
||||
open_backup_lockfile(USER_CFG_LOCKFILE, None, true)
|
||||
}
|
||||
|
||||
pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
|
||||
|
||||
let content = proxmox::tools::fs::file_read_optional_string(USER_CFG_FILENAME)?
|
||||
@ -119,7 +123,7 @@ pub fn cached_config() -> Result<Arc<SectionConfigData>, Error> {
|
||||
|
||||
pub fn save_config(config: &SectionConfigData) -> Result<(), Error> {
|
||||
let raw = CONFIG.write(USER_CFG_FILENAME, &config)?;
|
||||
pbs_config::replace_backup_config(USER_CFG_FILENAME, raw.as_bytes())?;
|
||||
replace_backup_config(USER_CFG_FILENAME, raw.as_bytes())?;
|
||||
|
||||
// increase user cache generation
|
||||
// We use this in CachedUserInfo
|
||||
|
Reference in New Issue
Block a user