From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 11CB91FF141 for ; Tue, 30 Jun 2026 10:43:43 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 1ECBB21416; Tue, 30 Jun 2026 10:43:42 +0200 (CEST) From: Daniel Kral To: pve-devel@lists.proxmox.com Subject: [RFC PATCH guest-common] tunnel: treat reader_stderr as optional parameter in read_tunnel Date: Tue, 30 Jun 2026 10:43:32 +0200 Message-ID: <20260630084332.32566-1-d.kral@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1782809005163 X-SPAM-LEVEL: Spam detection results: 0 DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 7GD7O6BHZUFZR4R3UY5LYIWBWIVIX2UX X-Message-ID-Hash: 7GD7O6BHZUFZR4R3UY5LYIWBWIVIX2UX X-MailFrom: d.kral@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 X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The reader_stderr parameter was introduced for a specific use case for the users of fork_ssh_tunnel(). The other callers, such as fork_websocket_tunnel(), do not provide the parameter and the Perl interpreter will warn about this: Use of uninitialized value $reader_stderr in at /usr/share/perl5/PVE/Tunnel.pm line 77. readline() on unopened filehandle at /usr/share/perl5/PVE/Tunnel.pm line 77. Therefore, treat reader_stderr as an optional parameter by not reading from the handle if it is not provided. Fixes: 8c8aa63 ("tunnel: redirect stderr to log function") Signed-off-by: Daniel Kral --- src/PVE/Tunnel.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/PVE/Tunnel.pm b/src/PVE/Tunnel.pm index 148a8e2..68547a5 100644 --- a/src/PVE/Tunnel.pm +++ b/src/PVE/Tunnel.pm @@ -74,8 +74,10 @@ sub read_tunnel { }; my $err = $@; - while (my $line = <$reader_stderr>) { # $reader_stderr is set up as non-blocking - $tunnel->{log}->('warn', $line); + if (defined($reader_stderr)) { + while (my $line = <$reader_stderr>) { # $reader_stderr is set up as non-blocking + $tunnel->{log}->('warn', $line); + } } die "reading from tunnel failed: $err\n" if $err; -- 2.47.3