[pbs-devel] [PATCH v2 proxmox-backup 1/2] upid: add workaround for parsing broken termproxy userids

Stefan Reiter s.reiter at proxmox.com
Tue Sep 1 14:27:27 CEST 2020


Commit aafe8609 "d/postinst: fixup userid for older termproxy tasks"
does the fixup after the upgrade, which is fine for CLI upgrades, but
doesn't work for the GUI, as the termproxy instance used for upgrading
will write it's own tasklog (with the still broken version) after the
upgrade and postinst.

Instead, add a (temporary) workaround to the UPID parser to handle this.

Suggested-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---

v2:
* don't just match root

As discussed off-list with Dominik, it's debatable if we want this patch
together with the second one, or if the latter is enough on it's own. It does
fix a breakage, but it adds workaround code, and this is a Beta after all...

 src/server/upid.rs | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/server/upid.rs b/src/server/upid.rs
index 9fc5085b..786bf6ab 100644
--- a/src/server/upid.rs
+++ b/src/server/upid.rs
@@ -107,20 +107,32 @@ impl UPID {
     }
 }
 
+// This is a workaround for a bug which resulted in only the username instead of
+// the userid to be written to the 'active' file for older termproxy tasks
+// FIXME: Remove in future version
+fn parse_userid(worker_type: &str, userid: &str) -> Result<Userid, Error> {
+    if worker_type == "termproxy" && !userid.ends_with("@pam") {
+        format!("{}@pam", userid).parse()
+    } else {
+        userid.parse()
+    }
+}
 
 impl std::str::FromStr for UPID {
     type Err = Error;
 
     fn from_str(s: &str) -> Result<Self, Self::Err> {
         if let Some(cap) = PROXMOX_UPID_REGEX.captures(s) {
+            let worker_type = cap["wtype"].to_owned();
+            let userid = parse_userid(&worker_type, &cap["userid"])?;
             Ok(UPID {
                 pid: i32::from_str_radix(&cap["pid"], 16).unwrap(),
                 pstart: u64::from_str_radix(&cap["pstart"], 16).unwrap(),
                 starttime: i64::from_str_radix(&cap["starttime"], 16).unwrap(),
                 task_id: usize::from_str_radix(&cap["task_id"], 16).unwrap(),
-                worker_type: cap["wtype"].to_string(),
+                worker_type,
                 worker_id: if cap["wid"].is_empty() { None } else { Some(cap["wid"].to_string()) },
-                userid: cap["userid"].parse()?,
+                userid,
                 node: cap["node"].to_string(),
             })
         } else {
-- 
2.20.1






More information about the pbs-devel mailing list