From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id A607969E09 for ; Tue, 1 Sep 2020 10:40:31 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8C40C1A376 for ; Tue, 1 Sep 2020 10:40:01 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 392621A369 for ; Tue, 1 Sep 2020 10:40:00 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E51E744995 for ; Tue, 1 Sep 2020 10:39:59 +0200 (CEST) From: Stefan Reiter To: pbs-devel@lists.proxmox.com Date: Tue, 1 Sep 2020 10:39:52 +0200 Message-Id: <20200901083952.6096-1-s.reiter@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.051 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [upid.rs] Subject: [pbs-devel] [PATCH] upid: add workaround for parsing broken termproxy userids X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2020 08:40:31 -0000 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 Signed-off-by: Stefan Reiter --- 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 { + 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 { 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