public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Reiter <s.reiter@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH] upid: add workaround for parsing broken termproxy userids
Date: Tue,  1 Sep 2020 10:39:52 +0200	[thread overview]
Message-ID: <20200901083952.6096-1-s.reiter@proxmox.com> (raw)

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 the
case where just 'root' is entered as the userid for termproxy tasks.

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

We should probably also consider doing the postinst for some more versions to
come, to hopefully finally arrive at a point where no one has broken entries
anymore and we can remove the workaround again.

 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..e1ca9d36 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 == "root" {
+        Ok(Userid::root_userid().to_owned())
+    } 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





                 reply	other threads:[~2020-09-01  8:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200901083952.6096-1-s.reiter@proxmox.com \
    --to=s.reiter@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal