[pbs-devel] [PATCH proxmox-backup 1/4] get rid of backup at pam

Dietmar Maurer dietmar at proxmox.com
Fri Nov 6 08:11:35 CET 2020


---
 src/api2/config/sync.rs           |  4 ++--
 src/api2/pull.rs                  |  2 +-
 src/api2/types/userid.rs          | 12 ------------
 src/bin/proxmox-backup-proxy.rs   | 10 +++++-----
 src/server/email_notifications.rs |  8 +-------
 www/window/SyncJobEdit.js         |  2 +-
 6 files changed, 10 insertions(+), 28 deletions(-)

diff --git a/src/api2/config/sync.rs b/src/api2/config/sync.rs
index f9810369..bdad21e6 100644
--- a/src/api2/config/sync.rs
+++ b/src/api2/config/sync.rs
@@ -58,7 +58,7 @@ pub fn check_sync_job_modify_access(
                     && owner.user() == auth_id.user())
         },
         // default sync owner
-        None => auth_id == Authid::backup_auth_id(),
+        None => auth_id == Authid::root_auth_id(),
     };
 
     // same permission as changing ownership after syncing
@@ -511,7 +511,7 @@ acl:1:/remote/remote1/remotestore1:write at pbs:RemoteSyncOperator
     job.owner = Some(read_auth_id.clone());
     assert_eq!(check_sync_job_modify_access(&user_info, &write_auth_id, &job), false);
 
-    // also not to the default 'backup at pam'
+    // also not to the default 'root at pam'
     job.owner = None;
     assert_eq!(check_sync_job_modify_access(&user_info, &write_auth_id, &job), false);
 
diff --git a/src/api2/pull.rs b/src/api2/pull.rs
index 87015c72..7ac6308e 100644
--- a/src/api2/pull.rs
+++ b/src/api2/pull.rs
@@ -84,7 +84,7 @@ pub fn do_sync_job(
             let worker_future = async move {
 
                 let delete = sync_job.remove_vanished.unwrap_or(true);
-                let sync_owner = sync_job.owner.unwrap_or(Authid::backup_auth_id().clone());
+                let sync_owner = sync_job.owner.unwrap_or(Authid::root_auth_id().clone());
                 let (client, src_repo, tgt_store) = get_pull_parameters(&sync_job.store, &sync_job.remote, &sync_job.remote_store).await?;
 
                 worker.log(format!("Starting datastore sync job '{}'", job_id));
diff --git a/src/api2/types/userid.rs b/src/api2/types/userid.rs
index 9104de22..42271904 100644
--- a/src/api2/types/userid.rs
+++ b/src/api2/types/userid.rs
@@ -450,11 +450,6 @@ impl Userid {
         &self.data
     }
 
-    /// Get the "backup at pam" user id.
-    pub fn backup_userid() -> &'static Self {
-        &*BACKUP_USERID
-    }
-
     /// Get the "root at pam" user id.
     pub fn root_userid() -> &'static Self {
         &*ROOT_USERID
@@ -462,7 +457,6 @@ impl Userid {
 }
 
 lazy_static! {
-    pub static ref BACKUP_USERID: Userid = Userid::new("backup at pam".to_string(), 6);
     pub static ref ROOT_USERID: Userid = Userid::new("root at pam".to_string(), 4);
 }
 
@@ -596,11 +590,6 @@ impl Authid {
         }
     }
 
-    /// Get the "backup at pam" auth id.
-    pub fn backup_auth_id() -> &'static Self {
-        &*BACKUP_AUTHID
-    }
-
     /// Get the "root at pam" auth id.
     pub fn root_auth_id() -> &'static Self {
         &*ROOT_AUTHID
@@ -608,7 +597,6 @@ impl Authid {
 }
 
 lazy_static! {
-    pub static ref BACKUP_AUTHID: Authid = Authid::from(Userid::new("backup at pam".to_string(), 6));
     pub static ref ROOT_AUTHID: Authid = Authid::from(Userid::new("root at pam".to_string(), 4));
 }
 
diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index 5803f024..80f30e8d 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -377,7 +377,7 @@ async fn schedule_datastore_garbage_collection() {
             Err(_) => continue, // could not get lock
         };
 
-        let auth_id = Authid::backup_auth_id();
+        let auth_id = Authid::root_auth_id();
 
         if let Err(err) = crate::server::do_garbage_collection_job(job, datastore, auth_id, Some(event_str), false) {
             eprintln!("unable to start garbage collection job on datastore {} - {}", store, err);
@@ -440,7 +440,7 @@ async fn schedule_datastore_prune() {
                 Err(_) => continue, // could not get lock
             };
 
-            let auth_id = Authid::backup_auth_id().clone();
+            let auth_id = Authid::root_auth_id().clone();
             if let Err(err) = do_prune_job(job, prune_options, store.clone(), &auth_id, Some(event_str)) {
                 eprintln!("unable to start datastore prune job {} - {}", &store, err);
             }
@@ -484,7 +484,7 @@ async fn schedule_datastore_sync_jobs() {
                 Err(_) => continue, // could not get lock
             };
 
-            let auth_id = Authid::backup_auth_id().clone();
+            let auth_id = Authid::root_auth_id().clone();
             if let Err(err) = do_sync_job(job, job_config, &auth_id, Some(event_str)) {
                 eprintln!("unable to start datastore sync job {} - {}", &job_id, err);
             }
@@ -520,7 +520,7 @@ async fn schedule_datastore_verify_jobs() {
         };
 
         let worker_type = "verificationjob";
-        let auth_id = Authid::backup_auth_id().clone();
+        let auth_id = Authid::root_auth_id().clone();
         if check_schedule(worker_type, &event_str, &job_id) {
             let job = match Job::new(&worker_type, &job_id) {
                 Ok(job) => job,
@@ -560,7 +560,7 @@ async fn schedule_task_log_rotate() {
     if let Err(err) = WorkerTask::new_thread(
         worker_type,
         None,
-        Authid::backup_auth_id().clone(),
+        Authid::root_auth_id().clone(),
         false,
         move |worker| {
             job.start(&worker.upid().to_string())?;
diff --git a/src/server/email_notifications.rs b/src/server/email_notifications.rs
index a4383361..7a835e3f 100644
--- a/src/server/email_notifications.rs
+++ b/src/server/email_notifications.rs
@@ -397,16 +397,10 @@ pub fn send_updates_available(
 }
 
 /// Lookup users email address
-///
-/// For "backup at pam", this returns the address from "root at pam".
 fn lookup_user_email(userid: &Userid) -> Option<String> {
 
     use crate::config::user::{self, User};
 
-    if userid == Userid::backup_userid() {
-        return lookup_user_email(Userid::root_userid());
-    }
-
     if let Ok(user_config) = user::cached_config() {
         if let Ok(user) = user_config.lookup::<User>("user", userid.as_str()) {
             return user.email.clone();
@@ -437,7 +431,7 @@ pub fn lookup_datastore_notify_settings(
 
     email = match config.notify_user {
         Some(ref userid) => lookup_user_email(userid),
-        None => lookup_user_email(Userid::backup_userid()),
+        None => lookup_user_email(Userid::root_userid()),
     };
 
     let notify_str = config.notify.unwrap_or(String::new());
diff --git a/www/window/SyncJobEdit.js b/www/window/SyncJobEdit.js
index c3c0e228..df1f2c5b 100644
--- a/www/window/SyncJobEdit.js
+++ b/www/window/SyncJobEdit.js
@@ -142,7 +142,7 @@ Ext.define('PBS.window.SyncJobEdit', {
 		name: 'owner',
 		allowBlank: true,
 		value: null,
-		emptyText: 'backup at pam',
+		emptyText: 'root at pam',
 		skipEmptyText: true,
 		cbind: {
 		    deleteEmpty: '{!isCreate}',
-- 
2.20.1





More information about the pbs-devel mailing list