From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id A9F961FF13F for ; Thu, 18 Jun 2026 13:05:09 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 31625148CA; Thu, 18 Jun 2026 13:05:08 +0200 (CEST) From: Erik Fastermann To: pve-devel@lists.proxmox.com Subject: [PATCH pve-guest-common] tunnel: websocket: prepend api token name when missing Date: Thu, 18 Jun 2026 13:04:33 +0200 Message-ID: <20260618110433.124789-1-e.fastermann@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.110 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an 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. [tunnel.pm] Message-ID-Hash: MV6MWMY4ELVSWGSSFDEXYWSPJEZHAUI6 X-Message-ID-Hash: MV6MWMY4ELVSWGSSFDEXYWSPJEZHAUI6 X-MailFrom: efastermann@ruth.proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Erik Fastermann X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Ensure that the API token used in `fork_websocket_tunnel` is properly prefixed with 'PVEAPIToken=' if it isn't already. Previously, if a token was supplied without this explicit prefix, initial API checks would pass successfully, but QEMU and LXC migrations would abruptly fail midway with the error "server didn't upgrade: 401 Unauthorized" when attempting to establish the websocket tunnel. This inconsistency created a confusing user experience, as the migration appeared to work fine initially. The early API checks succeeded because `PVE::APIClient::LWP` already automatically handles the missing prefix. This change brings the websocket tunnel setup in line with that behavior, preventing mid- migration failures when the prefix is omitted. Signed-off-by: Erik Fastermann --- src/PVE/Tunnel.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PVE/Tunnel.pm b/src/PVE/Tunnel.pm index 791b465..10f2bd6 100644 --- a/src/PVE/Tunnel.pm +++ b/src/PVE/Tunnel.pm @@ -234,6 +234,9 @@ sub fork_websocket_tunnel { my ($conn, $url, $req_params, $tunnel_params, $log) = @_; if (my $apitoken = $conn->{apitoken}) { + if ($apitoken !~ /^\w+(?:=| )/) { + $apitoken = "PVEAPIToken=${apitoken}"; + } $tunnel_params->{headers} = [["Authorization", "$apitoken"]]; } else { die "can't connect to remote host without credentials\n"; -- 2.47.3