move user configuration to pbs_config workspace

Also moved memcom.rs and cached_user_info.rs
This commit is contained in:
Dietmar Maurer 2021-09-10 06:53:53 +02:00
parent b65dfff574
commit ba3d7e19fb
42 changed files with 87 additions and 86 deletions

View File

@ -14,7 +14,7 @@ serde_json = "1.0"
openssl = "0.10" openssl = "0.10"
nix = "0.19.1" nix = "0.19.1"
regex = "1.2" regex = "1.2"
once_cell = "1.3.1"
proxmox = { version = "0.13.0", default-features = false, features = [ "cli" ] } proxmox = { version = "0.13.0", default-features = false, features = [ "cli" ] }

View File

@ -10,9 +10,9 @@ use proxmox::api::UserInformation;
use proxmox::tools::time::epoch_i64; use proxmox::tools::time::epoch_i64;
use pbs_api_types::{Authid, Userid, User, ApiToken, ROLE_ADMIN}; use pbs_api_types::{Authid, Userid, User, ApiToken, ROLE_ADMIN};
use pbs_config::acl::{AclTree, ROLE_NAMES};
use crate::tools::Memcom; use crate::acl::{AclTree, ROLE_NAMES};
use crate::memcom::Memcom;
/// Cache User/Group/Token/Acl configuration data for fast permission tests /// Cache User/Group/Token/Acl configuration data for fast permission tests
pub struct CachedUserInfo { pub struct CachedUserInfo {
@ -53,8 +53,8 @@ impl CachedUserInfo {
} }
let config = Arc::new(CachedUserInfo { let config = Arc::new(CachedUserInfo {
user_cfg: super::user::cached_config()?, user_cfg: crate::user::cached_config()?,
acl_tree: pbs_config::acl::cached_config()?, acl_tree: crate::acl::cached_config()?,
}); });
let mut cache = CACHED_CONFIG.write().unwrap(); let mut cache = CACHED_CONFIG.write().unwrap();
@ -65,8 +65,9 @@ impl CachedUserInfo {
Ok(config) Ok(config)
} }
#[cfg(test)] /// Only exposed for testing
pub(crate) fn test_new(user_cfg: SectionConfigData, acl_tree: AclTree) -> Self { #[doc(hidden)]
pub fn test_new(user_cfg: SectionConfigData, acl_tree: AclTree) -> Self {
Self { Self {
user_cfg: Arc::new(user_cfg), user_cfg: Arc::new(user_cfg),
acl_tree: Arc::new(acl_tree), acl_tree: Arc::new(acl_tree),

View File

@ -1,4 +1,6 @@
pub mod acl; pub mod acl;
mod cached_user_info;
pub use cached_user_info::CachedUserInfo;
pub mod domains; pub mod domains;
pub mod drive; pub mod drive;
pub mod key_config; pub mod key_config;
@ -9,8 +11,11 @@ pub mod sync;
pub mod tape_encryption_keys; pub mod tape_encryption_keys;
pub mod tape_job; pub mod tape_job;
pub mod token_shadow; pub mod token_shadow;
pub mod user;
pub mod verify; pub mod verify;
pub(crate) mod memcom;
use anyhow::{format_err, Error}; use anyhow::{format_err, Error};
pub use pbs_buildcfg::{BACKUP_USER_NAME, BACKUP_GROUP_NAME}; pub use pbs_buildcfg::{BACKUP_USER_NAME, BACKUP_GROUP_NAME};

View File

@ -38,7 +38,7 @@ impl Memcom {
// Actual work of `new`: // Actual work of `new`:
fn open() -> Result<Arc<Self>, Error> { fn open() -> Result<Arc<Self>, Error> {
let user = pbs_config::backup_user()?; let user = crate::backup_user()?;
let options = CreateOptions::new() let options = CreateOptions::new()
.perm(Mode::from_bits_truncate(0o660)) .perm(Mode::from_bits_truncate(0o660))
.owner(user.uid) .owner(user.uid)

View File

@ -16,9 +16,10 @@ use proxmox::api::{
use pbs_api_types::{ use pbs_api_types::{
Authid, Userid, ApiToken, User, Authid, Userid, ApiToken, User,
}; };
use pbs_config::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
use crate::tools::Memcom; use crate::memcom::Memcom;
use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
lazy_static! { lazy_static! {
pub static ref CONFIG: SectionConfig = init(); pub static ref CONFIG: SectionConfig = init();
@ -133,8 +134,9 @@ pub fn save_config(config: &SectionConfigData) -> Result<(), Error> {
Ok(()) Ok(())
} }
#[cfg(test)] /// Only exposed for testing
pub(crate) fn test_cfg_from_str(raw: &str) -> Result<(SectionConfigData, [u8;32]), Error> { #[doc(hidden)]
pub fn test_cfg_from_str(raw: &str) -> Result<(SectionConfigData, [u8;32]), Error> {
let cfg = init(); let cfg = init();
let parsed = cfg.parse("test_user_cfg", raw)?; let parsed = cfg.parse("test_user_cfg", raw)?;

View File

@ -12,7 +12,7 @@ use pbs_api_types::{
use pbs_config::acl::AclTreeNode; use pbs_config::acl::AclTreeNode;
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
fn extract_acl_node_data( fn extract_acl_node_data(
node: &AclTreeNode, node: &AclTreeNode,
@ -221,7 +221,7 @@ pub fn update_acl(
bail!("parameter 'group' - groups are currently not supported."); bail!("parameter 'group' - groups are currently not supported.");
} else if let Some(ref auth_id) = auth_id { } else if let Some(ref auth_id) = auth_id {
if !delete { // Note: we allow to delete non-existent users if !delete { // Note: we allow to delete non-existent users
let user_cfg = crate::config::user::cached_config()?; let user_cfg = pbs_config::user::cached_config()?;
if user_cfg.sections.get(&auth_id.to_string()).is_none() { if user_cfg.sections.get(&auth_id.to_string()).is_none() {
bail!(format!("no such {}.", bail!(format!("no such {}.",
if auth_id.is_token() { "API token" } else { "user" })); if auth_id.is_token() { "API token" } else { "user" }));

View File

@ -22,7 +22,7 @@ use pbs_config::acl::AclTreeNode;
use crate::auth_helpers::*; use crate::auth_helpers::*;
use crate::server::ticket::ApiTicket; use crate::server::ticket::ApiTicket;
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
use crate::config::tfa::TfaChallenge; use crate::config::tfa::TfaChallenge;
pub mod acl; pub mod acl;

View File

@ -19,7 +19,7 @@ use pbs_tools::ticket::Ticket;
use pbs_config::domains::{OpenIdUserAttribute, OpenIdRealmConfig}; use pbs_config::domains::{OpenIdUserAttribute, OpenIdRealmConfig};
use crate::server::ticket::ApiTicket; use crate::server::ticket::ApiTicket;
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
use pbs_config::open_backup_lockfile; use pbs_config::open_backup_lockfile;
@ -116,7 +116,7 @@ pub fn openid_login(
if !user_info.is_active_user_id(&user_id) { if !user_info.is_active_user_id(&user_id) {
if config.autocreate.unwrap_or(false) { if config.autocreate.unwrap_or(false) {
use crate::config::user; use pbs_config::user;
let _lock = open_backup_lockfile(user::USER_CFG_LOCKFILE, None, true)?; let _lock = open_backup_lockfile(user::USER_CFG_LOCKFILE, None, true)?;
let user = User { let user = User {
userid: user_id.clone(), userid: user_id.clone(),

View File

@ -9,7 +9,7 @@ use proxmox::{http_bail, http_err};
use pbs_api_types::{Authid, Userid, User, PASSWORD_SCHEMA, PRIV_PERMISSIONS_MODIFY, PRIV_SYS_AUDIT}; use pbs_api_types::{Authid, Userid, User, PASSWORD_SCHEMA, PRIV_PERMISSIONS_MODIFY, PRIV_SYS_AUDIT};
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
use crate::config::tfa::{TfaInfo, TfaUserData}; use crate::config::tfa::{TfaInfo, TfaUserData};
/// Perform first-factor (password) authentication only. Ignore password for the root user. /// Perform first-factor (password) authentication only. Ignore password for the root user.
@ -34,7 +34,7 @@ fn tfa_update_auth(
// After authentication, verify that the to-be-modified user actually exists: // After authentication, verify that the to-be-modified user actually exists:
if must_exist && authid.user() != userid { if must_exist && authid.user() != userid {
let (config, _digest) = crate::config::user::config()?; let (config, _digest) = pbs_config::user::config()?;
if config if config
.lookup::<User>("user", userid.as_str()) .lookup::<User>("user", userid.as_str())

View File

@ -16,7 +16,7 @@ use pbs_api_types::{
}; };
use pbs_config::token_shadow; use pbs_config::token_shadow;
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
fn new_user_with_tokens(user: User) -> UserWithTokens { fn new_user_with_tokens(user: User) -> UserWithTokens {
UserWithTokens { UserWithTokens {
@ -59,7 +59,7 @@ pub fn list_users(
mut rpcenv: &mut dyn RpcEnvironment, mut rpcenv: &mut dyn RpcEnvironment,
) -> Result<Vec<UserWithTokens>, Error> { ) -> Result<Vec<UserWithTokens>, Error> {
let (config, digest) = crate::config::user::config()?; let (config, digest) = pbs_config::user::config()?;
let auth_id: Authid = rpcenv let auth_id: Authid = rpcenv
.get_auth_id() .get_auth_id()
@ -138,9 +138,9 @@ pub fn create_user(
rpcenv: &mut dyn RpcEnvironment rpcenv: &mut dyn RpcEnvironment
) -> Result<(), Error> { ) -> Result<(), Error> {
let _lock = crate::config::user::lock_config()?; let _lock = pbs_config::user::lock_config()?;
let (mut section_config, _digest) = crate::config::user::config()?; let (mut section_config, _digest) = pbs_config::user::config()?;
if section_config.sections.get(config.userid.as_str()).is_some() { if section_config.sections.get(config.userid.as_str()).is_some() {
bail!("user '{}' already exists.", config.userid); bail!("user '{}' already exists.", config.userid);
@ -153,7 +153,7 @@ pub fn create_user(
// Fails if realm does not exist! // Fails if realm does not exist!
let authenticator = crate::auth::lookup_authenticator(realm)?; let authenticator = crate::auth::lookup_authenticator(realm)?;
crate::config::user::save_config(&section_config)?; pbs_config::user::save_config(&section_config)?;
if let Some(password) = password { if let Some(password) = password {
let user_info = CachedUserInfo::new()?; let user_info = CachedUserInfo::new()?;
@ -185,7 +185,7 @@ pub fn create_user(
)] )]
/// Read user configuration data. /// Read user configuration data.
pub fn read_user(userid: Userid, mut rpcenv: &mut dyn RpcEnvironment) -> Result<User, Error> { pub fn read_user(userid: Userid, mut rpcenv: &mut dyn RpcEnvironment) -> Result<User, Error> {
let (config, digest) = crate::config::user::config()?; let (config, digest) = pbs_config::user::config()?;
let user = config.lookup("user", userid.as_str())?; let user = config.lookup("user", userid.as_str())?;
rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into(); rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
Ok(user) Ok(user)
@ -253,9 +253,9 @@ pub fn update_user(
rpcenv: &mut dyn RpcEnvironment, rpcenv: &mut dyn RpcEnvironment,
) -> Result<(), Error> { ) -> Result<(), Error> {
let _lock = crate::config::user::lock_config()?; let _lock = pbs_config::user::lock_config()?;
let (mut config, expected_digest) = crate::config::user::config()?; let (mut config, expected_digest) = pbs_config::user::config()?;
if let Some(ref digest) = digest { if let Some(ref digest) = digest {
let digest = proxmox::tools::hex_to_digest(digest)?; let digest = proxmox::tools::hex_to_digest(digest)?;
@ -317,7 +317,7 @@ pub fn update_user(
config.set_data(userid.as_str(), "user", &data)?; config.set_data(userid.as_str(), "user", &data)?;
crate::config::user::save_config(&config)?; pbs_config::user::save_config(&config)?;
Ok(()) Ok(())
} }
@ -345,10 +345,10 @@ pub fn update_user(
/// Remove a user from the configuration file. /// Remove a user from the configuration file.
pub fn delete_user(userid: Userid, digest: Option<String>) -> Result<(), Error> { pub fn delete_user(userid: Userid, digest: Option<String>) -> Result<(), Error> {
let _lock = crate::config::user::lock_config()?; let _lock = pbs_config::user::lock_config()?;
let _tfa_lock = crate::config::tfa::write_lock()?; let _tfa_lock = crate::config::tfa::write_lock()?;
let (mut config, expected_digest) = crate::config::user::config()?; let (mut config, expected_digest) = pbs_config::user::config()?;
if let Some(ref digest) = digest { if let Some(ref digest) = digest {
let digest = proxmox::tools::hex_to_digest(digest)?; let digest = proxmox::tools::hex_to_digest(digest)?;
@ -360,7 +360,7 @@ pub fn delete_user(userid: Userid, digest: Option<String>) -> Result<(), Error>
None => bail!("user '{}' does not exist.", userid), None => bail!("user '{}' does not exist.", userid),
} }
crate::config::user::save_config(&config)?; pbs_config::user::save_config(&config)?;
let authenticator = crate::auth::lookup_authenticator(userid.realm())?; let authenticator = crate::auth::lookup_authenticator(userid.realm())?;
match authenticator.remove_password(userid.name()) { match authenticator.remove_password(userid.name()) {
@ -416,7 +416,7 @@ pub fn read_token(
mut rpcenv: &mut dyn RpcEnvironment, mut rpcenv: &mut dyn RpcEnvironment,
) -> Result<ApiToken, Error> { ) -> Result<ApiToken, Error> {
let (config, digest) = crate::config::user::config()?; let (config, digest) = pbs_config::user::config()?;
let tokenid = Authid::from((userid, Some(tokenname))); let tokenid = Authid::from((userid, Some(tokenname)));
@ -482,9 +482,9 @@ pub fn generate_token(
digest: Option<String>, digest: Option<String>,
) -> Result<Value, Error> { ) -> Result<Value, Error> {
let _lock = crate::config::user::lock_config()?; let _lock = pbs_config::user::lock_config()?;
let (mut config, expected_digest) = crate::config::user::config()?; let (mut config, expected_digest) = pbs_config::user::config()?;
if let Some(ref digest) = digest { if let Some(ref digest) = digest {
let digest = proxmox::tools::hex_to_digest(digest)?; let digest = proxmox::tools::hex_to_digest(digest)?;
@ -510,7 +510,7 @@ pub fn generate_token(
config.set_data(&tokenid_string, "token", &token)?; config.set_data(&tokenid_string, "token", &token)?;
crate::config::user::save_config(&config)?; pbs_config::user::save_config(&config)?;
Ok(json!({ Ok(json!({
"tokenid": tokenid_string, "tokenid": tokenid_string,
@ -563,9 +563,9 @@ pub fn update_token(
digest: Option<String>, digest: Option<String>,
) -> Result<(), Error> { ) -> Result<(), Error> {
let _lock = crate::config::user::lock_config()?; let _lock = pbs_config::user::lock_config()?;
let (mut config, expected_digest) = crate::config::user::config()?; let (mut config, expected_digest) = pbs_config::user::config()?;
if let Some(ref digest) = digest { if let Some(ref digest) = digest {
let digest = proxmox::tools::hex_to_digest(digest)?; let digest = proxmox::tools::hex_to_digest(digest)?;
@ -596,7 +596,7 @@ pub fn update_token(
config.set_data(&tokenid_string, "token", &data)?; config.set_data(&tokenid_string, "token", &data)?;
crate::config::user::save_config(&config)?; pbs_config::user::save_config(&config)?;
Ok(()) Ok(())
} }
@ -631,9 +631,9 @@ pub fn delete_token(
digest: Option<String>, digest: Option<String>,
) -> Result<(), Error> { ) -> Result<(), Error> {
let _lock = crate::config::user::lock_config()?; let _lock = pbs_config::user::lock_config()?;
let (mut config, expected_digest) = crate::config::user::config()?; let (mut config, expected_digest) = pbs_config::user::config()?;
if let Some(ref digest) = digest { if let Some(ref digest) = digest {
let digest = proxmox::tools::hex_to_digest(digest)?; let digest = proxmox::tools::hex_to_digest(digest)?;
@ -650,7 +650,7 @@ pub fn delete_token(
token_shadow::delete_secret(&tokenid)?; token_shadow::delete_secret(&tokenid)?;
crate::config::user::save_config(&config)?; pbs_config::user::save_config(&config)?;
Ok(()) Ok(())
} }
@ -682,7 +682,7 @@ pub fn list_tokens(
mut rpcenv: &mut dyn RpcEnvironment, mut rpcenv: &mut dyn RpcEnvironment,
) -> Result<Vec<ApiToken>, Error> { ) -> Result<Vec<ApiToken>, Error> {
let (config, digest) = crate::config::user::config()?; let (config, digest) = pbs_config::user::config()?;
let list:Vec<ApiToken> = config.convert_to_typed_array("token")?; let list:Vec<ApiToken> = config.convert_to_typed_array("token")?;

View File

@ -58,7 +58,7 @@ use crate::backup::{
DataStore, LocalChunkReader, DataStore, LocalChunkReader,
}; };
use crate::config::datastore; use crate::config::datastore;
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
use crate::server::{jobstate::Job, WorkerTask}; use crate::server::{jobstate::Job, WorkerTask};

View File

@ -9,6 +9,7 @@ use proxmox::{list_subdirs_api_method, sortable};
use pbs_api_types::{DATASTORE_SCHEMA, JOB_ID_SCHEMA, Authid, SyncJobConfig, SyncJobStatus}; use pbs_api_types::{DATASTORE_SCHEMA, JOB_ID_SCHEMA, Authid, SyncJobConfig, SyncJobStatus};
use pbs_config::sync; use pbs_config::sync;
use pbs_config::CachedUserInfo;
use crate::{ use crate::{
api2::{ api2::{
@ -18,9 +19,6 @@ use crate::{
check_sync_job_read_access, check_sync_job_read_access,
}, },
}, },
config::{
cached_user_info::CachedUserInfo,
},
server::{ server::{
jobstate::{ jobstate::{
Job, Job,

View File

@ -12,6 +12,7 @@ use pbs_api_types::{
PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_VERIFY, PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_VERIFY,
}; };
use pbs_config::verify; use pbs_config::verify;
use pbs_config::CachedUserInfo;
use crate::{ use crate::{
api2::types::{ api2::types::{
@ -25,7 +26,6 @@ use crate::{
compute_schedule_status, compute_schedule_status,
}, },
}, },
config::cached_user_info::CachedUserInfo,
}; };
#[api( #[api(

View File

@ -26,7 +26,7 @@ use pbs_datastore::manifest::{archive_type, ArchiveType};
use crate::server::{WorkerTask, H2Service}; use crate::server::{WorkerTask, H2Service};
use crate::backup::DataStore; use crate::backup::DataStore;
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
mod environment; mod environment;
use environment::*; use environment::*;

View File

@ -15,9 +15,9 @@ use pbs_api_types::{
PROXMOX_CONFIG_DIGEST_SCHEMA, CHANGER_NAME_SCHEMA, SLOT_ARRAY_SCHEMA, PROXMOX_CONFIG_DIGEST_SCHEMA, CHANGER_NAME_SCHEMA, SLOT_ARRAY_SCHEMA,
PRIV_TAPE_AUDIT, PRIV_TAPE_MODIFY, PRIV_TAPE_AUDIT, PRIV_TAPE_MODIFY,
}; };
use pbs_config::CachedUserInfo;
use crate::{ use crate::{
config::cached_user_info::CachedUserInfo,
tape::{ tape::{
linux_tape_changer_list, linux_tape_changer_list,
check_drive_path, check_drive_path,

View File

@ -24,7 +24,7 @@ use crate::api2::admin::{
sync::list_sync_jobs, sync::list_sync_jobs,
verify::list_verification_jobs, verify::list_verification_jobs,
}; };
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
use crate::config::datastore::{self, DataStoreConfig, DataStoreConfigUpdater}; use crate::config::datastore::{self, DataStoreConfig, DataStoreConfigUpdater};
use crate::server::{jobstate, WorkerTask}; use crate::server::{jobstate, WorkerTask};

View File

@ -8,9 +8,9 @@ use pbs_api_types::{
Authid, LtoTapeDrive, LtoTapeDriveUpdater, ScsiTapeChanger, Authid, LtoTapeDrive, LtoTapeDriveUpdater, ScsiTapeChanger,
PROXMOX_CONFIG_DIGEST_SCHEMA, DRIVE_NAME_SCHEMA, PRIV_TAPE_AUDIT, PRIV_TAPE_MODIFY, PROXMOX_CONFIG_DIGEST_SCHEMA, DRIVE_NAME_SCHEMA, PRIV_TAPE_AUDIT, PRIV_TAPE_MODIFY,
}; };
use pbs_config::CachedUserInfo;
use crate::{ use crate::{
config::cached_user_info::CachedUserInfo,
tape::{ tape::{
lto_tape_device_list, lto_tape_device_list,
check_drive_path, check_drive_path,

View File

@ -15,7 +15,7 @@ use pbs_api_types::{
PRIV_TAPE_AUDIT, PRIV_TAPE_MODIFY, PRIV_TAPE_AUDIT, PRIV_TAPE_MODIFY,
}; };
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
#[api( #[api(
protected: true, protected: true,

View File

@ -13,7 +13,7 @@ use pbs_api_types::{
}; };
use pbs_config::sync; use pbs_config::sync;
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
#[api( #[api(
input: { input: {

View File

@ -11,7 +11,7 @@ use pbs_api_types::{
}; };
use pbs_config::sync; use pbs_config::sync;
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
pub fn check_sync_job_read_access( pub fn check_sync_job_read_access(
user_info: &CachedUserInfo, user_info: &CachedUserInfo,
@ -356,7 +356,7 @@ pub const ROUTER: Router = Router::new()
#[test] #[test]
fn sync_job_access_test() -> Result<(), Error> { fn sync_job_access_test() -> Result<(), Error> {
let (user_cfg, _) = crate::config::user::test_cfg_from_str(r###" let (user_cfg, _) = pbs_config::user::test_cfg_from_str(r###"
user: noperm@pbs user: noperm@pbs
user: read@pbs user: read@pbs

View File

@ -10,7 +10,7 @@ use pbs_api_types::{
PRIV_TAPE_AUDIT, PRIV_TAPE_MODIFY, PRIV_TAPE_AUDIT, PRIV_TAPE_MODIFY,
}; };
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
#[api( #[api(
input: { input: {

View File

@ -10,7 +10,7 @@ use pbs_api_types::{
}; };
use pbs_config::verify; use pbs_config::verify;
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
#[api( #[api(
input: { input: {

View File

@ -10,7 +10,7 @@ use pbs_api_types::{
use crate::tools; use crate::tools;
use crate::tools::subscription::{self, SubscriptionStatus, SubscriptionInfo}; use crate::tools::subscription::{self, SubscriptionStatus, SubscriptionInfo};
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
#[api( #[api(
input: { input: {

View File

@ -18,7 +18,7 @@ use pbs_api_types::{
use crate::api2::types::TaskStateType; use crate::api2::types::TaskStateType;
use crate::api2::pull::check_pull_privs; use crate::api2::pull::check_pull_privs;
use crate::server::{self, UPID, UPIDExt, TaskState, TaskListInfoIterator}; use crate::server::{self, UPID, UPIDExt, TaskState, TaskListInfoIterator};
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
// matches respective job execution privileges // matches respective job execution privileges
fn check_job_privs(auth_id: &Authid, user_info: &CachedUserInfo, upid: &UPID) -> Result<(), Error> { fn check_job_privs(auth_id: &Authid, user_info: &CachedUserInfo, upid: &UPID) -> Result<(), Error> {

View File

@ -16,7 +16,7 @@ use pbs_api_types::{
use crate::server::{WorkerTask, jobstate::Job, pull::pull_store}; use crate::server::{WorkerTask, jobstate::Job, pull::pull_store};
use crate::backup::DataStore; use crate::backup::DataStore;
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
pub fn check_pull_privs( pub fn check_pull_privs(
auth_id: &Authid, auth_id: &Authid,

View File

@ -37,6 +37,7 @@ use pbs_datastore::PROXMOX_BACKUP_READER_PROTOCOL_ID_V1;
use pbs_datastore::backup_info::BackupDir; use pbs_datastore::backup_info::BackupDir;
use pbs_datastore::index::IndexFile; use pbs_datastore::index::IndexFile;
use pbs_datastore::manifest::{archive_type, ArchiveType}; use pbs_datastore::manifest::{archive_type, ArchiveType};
use pbs_config::CachedUserInfo;
use crate::{ use crate::{
api2::helpers, api2::helpers,
@ -45,7 +46,6 @@ use crate::{
WorkerTask, WorkerTask,
H2Service, H2Service,
}, },
config::cached_user_info::CachedUserInfo,
}; };
mod environment; mod environment;

View File

@ -22,7 +22,7 @@ use pbs_api_types::{
use crate::backup::DataStore; use crate::backup::DataStore;
use crate::config::datastore; use crate::config::datastore;
use crate::tools::statistics::{linear_regression}; use crate::tools::statistics::{linear_regression};
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
#[api( #[api(
returns: { returns: {

View File

@ -23,9 +23,9 @@ use pbs_api_types::{
use pbs_datastore::{task_log, task_warn, StoreProgress}; use pbs_datastore::{task_log, task_warn, StoreProgress};
use pbs_datastore::backup_info::{BackupDir, BackupInfo}; use pbs_datastore::backup_info::{BackupDir, BackupInfo};
use pbs_datastore::task::TaskState; use pbs_datastore::task::TaskState;
use pbs_config::CachedUserInfo;
use crate::{ use crate::{
config::cached_user_info::CachedUserInfo,
server::{ server::{
lookup_user_email, lookup_user_email,
TapeBackupJobSummary, TapeBackupJobSummary,

View File

@ -11,9 +11,9 @@ use pbs_api_types::{
Authid, ChangerListEntry, LtoTapeDrive, MtxEntryKind, MtxStatusEntry, ScsiTapeChanger, Authid, ChangerListEntry, LtoTapeDrive, MtxEntryKind, MtxStatusEntry, ScsiTapeChanger,
CHANGER_NAME_SCHEMA, PRIV_TAPE_AUDIT, PRIV_TAPE_READ, CHANGER_NAME_SCHEMA, PRIV_TAPE_AUDIT, PRIV_TAPE_READ,
}; };
use pbs_config::CachedUserInfo;
use crate::{ use crate::{
config::cached_user_info::CachedUserInfo,
tape::{ tape::{
TAPE_STATUS_DIR, TAPE_STATUS_DIR,
Inventory, Inventory,

View File

@ -30,9 +30,9 @@ use pbs_api_types::{
use pbs_datastore::task_log; use pbs_datastore::task_log;
use pbs_api_types::{PRIV_TAPE_AUDIT, PRIV_TAPE_READ, PRIV_TAPE_WRITE}; use pbs_api_types::{PRIV_TAPE_AUDIT, PRIV_TAPE_READ, PRIV_TAPE_WRITE};
use pbs_config::CachedUserInfo;
use crate::{ use crate::{
config::cached_user_info::CachedUserInfo,
api2::tape::restore::{ api2::tape::restore::{
fast_catalog_restore, fast_catalog_restore,
restore_media, restore_media,

View File

@ -16,9 +16,9 @@ use pbs_api_types::{
MediaStatus, MediaContentEntry, MediaContentListFilter, MediaStatus, MediaContentEntry, MediaContentListFilter,
PRIV_TAPE_AUDIT, PRIV_TAPE_AUDIT,
}; };
use pbs_config::CachedUserInfo;
use crate::{ use crate::{
config::cached_user_info::CachedUserInfo,
tape::{ tape::{
TAPE_STATUS_DIR, TAPE_STATUS_DIR,
Inventory, Inventory,

View File

@ -41,10 +41,10 @@ use pbs_datastore::fixed_index::FixedIndexReader;
use pbs_datastore::index::IndexFile; use pbs_datastore::index::IndexFile;
use pbs_datastore::manifest::{archive_type, ArchiveType, BackupManifest, MANIFEST_BLOB_NAME}; use pbs_datastore::manifest::{archive_type, ArchiveType, BackupManifest, MANIFEST_BLOB_NAME};
use pbs_datastore::task::TaskState; use pbs_datastore::task::TaskState;
use pbs_config::CachedUserInfo;
use crate::{ use crate::{
tools::ParallelHandler, tools::ParallelHandler,
config::cached_user_info::CachedUserInfo,
backup::DataStore, backup::DataStore,
server::{ server::{
lookup_user_email, lookup_user_email,

View File

@ -53,7 +53,7 @@ fn main() -> Result<(), Error> {
"datastore.cfg" => dump_section_config(&config::datastore::CONFIG), "datastore.cfg" => dump_section_config(&config::datastore::CONFIG),
"tape.cfg" => dump_section_config(&pbs_config::drive::CONFIG), "tape.cfg" => dump_section_config(&pbs_config::drive::CONFIG),
"tape-job.cfg" => dump_section_config(&pbs_config::tape_job::CONFIG), "tape-job.cfg" => dump_section_config(&pbs_config::tape_job::CONFIG),
"user.cfg" => dump_section_config(&config::user::CONFIG), "user.cfg" => dump_section_config(&pbs_config::user::CONFIG),
"remote.cfg" => dump_section_config(&pbs_config::remote::CONFIG), "remote.cfg" => dump_section_config(&pbs_config::remote::CONFIG),
"sync.cfg" => dump_section_config(&pbs_config::sync::CONFIG), "sync.cfg" => dump_section_config(&pbs_config::sync::CONFIG),
"verification.cfg" => dump_section_config(&pbs_config::verify::CONFIG), "verification.cfg" => dump_section_config(&pbs_config::verify::CONFIG),

View File

@ -60,7 +60,7 @@ pub fn acl_commands() -> CommandLineInterface {
"update", "update",
CliCommand::new(&api2::access::acl::API_METHOD_UPDATE_ACL) CliCommand::new(&api2::access::acl::API_METHOD_UPDATE_ACL)
.arg_param(&["path", "role"]) .arg_param(&["path", "role"])
.completion_cb("auth-id", config::user::complete_authid) .completion_cb("auth-id", pbs_config::user::complete_authid)
.completion_cb("path", config::datastore::complete_acl_path) .completion_cb("path", config::datastore::complete_acl_path)
); );

View File

@ -181,38 +181,38 @@ pub fn user_commands() -> CommandLineInterface {
"update", "update",
CliCommand::new(&api2::access::user::API_METHOD_UPDATE_USER) CliCommand::new(&api2::access::user::API_METHOD_UPDATE_USER)
.arg_param(&["userid"]) .arg_param(&["userid"])
.completion_cb("userid", config::user::complete_userid) .completion_cb("userid", pbs_config::user::complete_userid)
) )
.insert( .insert(
"remove", "remove",
CliCommand::new(&api2::access::user::API_METHOD_DELETE_USER) CliCommand::new(&api2::access::user::API_METHOD_DELETE_USER)
.arg_param(&["userid"]) .arg_param(&["userid"])
.completion_cb("userid", config::user::complete_userid) .completion_cb("userid", pbs_config::user::complete_userid)
) )
.insert( .insert(
"list-tokens", "list-tokens",
CliCommand::new(&&API_METHOD_LIST_TOKENS) CliCommand::new(&&API_METHOD_LIST_TOKENS)
.arg_param(&["userid"]) .arg_param(&["userid"])
.completion_cb("userid", config::user::complete_userid) .completion_cb("userid", pbs_config::user::complete_userid)
) )
.insert( .insert(
"generate-token", "generate-token",
CliCommand::new(&api2::access::user::API_METHOD_GENERATE_TOKEN) CliCommand::new(&api2::access::user::API_METHOD_GENERATE_TOKEN)
.arg_param(&["userid", "tokenname"]) .arg_param(&["userid", "tokenname"])
.completion_cb("userid", config::user::complete_userid) .completion_cb("userid", pbs_config::user::complete_userid)
) )
.insert( .insert(
"delete-token", "delete-token",
CliCommand::new(&api2::access::user::API_METHOD_DELETE_TOKEN) CliCommand::new(&api2::access::user::API_METHOD_DELETE_TOKEN)
.arg_param(&["userid", "tokenname"]) .arg_param(&["userid", "tokenname"])
.completion_cb("userid", config::user::complete_userid) .completion_cb("userid", pbs_config::user::complete_userid)
.completion_cb("tokenname", config::user::complete_token_name) .completion_cb("tokenname", pbs_config::user::complete_token_name)
) )
.insert( .insert(
"permissions", "permissions",
CliCommand::new(&&API_METHOD_LIST_PERMISSIONS) CliCommand::new(&&API_METHOD_LIST_PERMISSIONS)
.arg_param(&["auth-id"]) .arg_param(&["auth-id"])
.completion_cb("auth-id", config::user::complete_authid) .completion_cb("auth-id", pbs_config::user::complete_authid)
.completion_cb("path", config::datastore::complete_acl_path) .completion_cb("path", config::datastore::complete_acl_path)
); );

View File

@ -6,7 +6,7 @@ use anyhow::{bail, format_err, Error};
use pbs_api_types::Authid; use pbs_api_types::Authid;
use proxmox_backup::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
use proxmox_backup::server::auth::{ApiAuth, AuthError}; use proxmox_backup::server::auth::{ApiAuth, AuthError};
const TICKET_FILE: &str = "/ticket"; const TICKET_FILE: &str = "/ticket";

View File

@ -15,11 +15,9 @@ use proxmox::try_block;
use pbs_buildcfg::{self, configdir}; use pbs_buildcfg::{self, configdir};
pub mod acme; pub mod acme;
pub mod cached_user_info;
pub mod datastore; pub mod datastore;
pub mod node; pub mod node;
pub mod tfa; pub mod tfa;
pub mod user;
/// Check configuration directory permissions /// Check configuration directory permissions
/// ///

View File

@ -8,7 +8,7 @@ use pbs_config::token_shadow;
use crate::api2::types::{Authid, Userid}; use crate::api2::types::{Authid, Userid};
use crate::auth_helpers::*; use crate::auth_helpers::*;
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
use crate::tools; use crate::tools;
use hyper::header; use hyper::header;

View File

@ -548,7 +548,7 @@ pub fn send_updates_available(
/// Lookup users email address /// Lookup users email address
pub fn lookup_user_email(userid: &Userid) -> Option<String> { pub fn lookup_user_email(userid: &Userid) -> Option<String> {
if let Ok(user_config) = crate::config::user::cached_config() { if let Ok(user_config) = pbs_config::user::cached_config() {
if let Ok(user) = user_config.lookup::<User>("user", userid.as_str()) { if let Ok(user) = user_config.lookup::<User>("user", userid.as_str()) {
return user.email; return user.email;
} }

View File

@ -6,9 +6,9 @@ use pbs_datastore::{task_log, task_warn};
use pbs_datastore::backup_info::BackupInfo; use pbs_datastore::backup_info::BackupInfo;
use pbs_datastore::prune::{compute_prune_info, PruneOptions}; use pbs_datastore::prune::{compute_prune_info, PruneOptions};
use pbs_api_types::{Authid, PRIV_DATASTORE_MODIFY}; use pbs_api_types::{Authid, PRIV_DATASTORE_MODIFY};
use pbs_config::CachedUserInfo;
use crate::{ use crate::{
config::cached_user_info::CachedUserInfo,
backup::DataStore, backup::DataStore,
server::jobstate::Job, server::jobstate::Job,
server::WorkerTask, server::WorkerTask,

View File

@ -40,7 +40,7 @@ use super::ApiConfig;
use crate::api2::types::{Authid, Userid}; use crate::api2::types::{Authid, Userid};
use crate::auth_helpers::*; use crate::auth_helpers::*;
use crate::config::cached_user_info::CachedUserInfo; use pbs_config::CachedUserInfo;
use crate::tools; use crate::tools;
use crate::tools::compression::CompressionMethod; use crate::tools::compression::CompressionMethod;
use crate::tools::FileLogger; use crate::tools::FileLogger;

View File

@ -28,9 +28,6 @@ pub mod config;
pub mod daemon; pub mod daemon;
pub mod disks; pub mod disks;
mod memcom;
pub use memcom::Memcom;
pub mod serde_filter; pub mod serde_filter;
pub mod statistics; pub mod statistics;
pub mod subscription; pub mod subscription;