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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id A68D062B35 for ; Thu, 1 Oct 2020 10:12:15 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A329D1EF72 for ; Thu, 1 Oct 2020 10:11:45 +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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id D46A11EF62 for ; Thu, 1 Oct 2020 10:11:44 +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 9D08645B92 for ; Thu, 1 Oct 2020 10:11:44 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Thu, 1 Oct 2020 10:11:36 +0200 Message-Id: <20201001081136.9795-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201001081136.9795-1-f.ebner@proxmox.com> References: <20201001081136.9795-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.049 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. [storage.pm] Subject: [pve-devel] [PATCH storage 2/2] fix #1452: also log stderr of remote command with insecure storage migration X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Oct 2020 08:12:15 -0000 Commit 8fe00d99449b7c80e81ab3c9826625a4fcd89aa4 already introduced the necessary logging for the secure code path, so presumably the bug was already fixed for most people. Delay the potential die for the send command to be able to log the ouput+error from the receive command. Like this we also see e.g. 'volume ... already exists' instead of just 'broken pipe'. Signed-off-by: Fabian Ebner --- PVE/Storage.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/PVE/Storage.pm b/PVE/Storage.pm index 4a60615..cd7b5ff 100755 --- a/PVE/Storage.pm +++ b/PVE/Storage.pm @@ -8,6 +8,7 @@ use POSIX; use IO::Select; use IO::File; use IO::Socket::IP; +use IPC::Open3; use File::Basename; use File::Path; use Cwd 'abs_path'; @@ -698,15 +699,22 @@ sub storage_migrate { volume_snapshot($cfg, $volid, $snapshot) if $migration_snapshot; eval { if ($insecure) { - open(my $info, '-|', @$recv) + my $input = IO::File->new(); + my $info = IO::File->new(); + open3($input, $info, $info, @{$recv}) or die "receive command failed: $!\n"; + close($input); + my ($ip) = <$info> =~ /^($PVE::Tools::IPRE)$/ or die "no tunnel IP received\n"; my ($port) = <$info> =~ /^(\d+)$/ or die "no tunnel port received\n"; my $socket = IO::Socket::IP->new(PeerHost => $ip, PeerPort => $port, Type => SOCK_STREAM) or die "failed to connect to tunnel at $ip:$port\n"; # we won't be reading from the socket shutdown($socket, 0); - run_command([$send, @cstream], output => '>&'.fileno($socket), errfunc => $logfunc); + + eval { run_command([$send, @cstream], output => '>&'.fileno($socket), errfunc => $logfunc); }; + my $send_error = $@; + # don't close the connection entirely otherwise the receiving end # might not get all buffered data (and fails with 'connection reset by peer') shutdown($socket, 1); @@ -722,6 +730,8 @@ sub storage_migrate { die "import failed: $!\n" if $!; die "import failed: exit code ".($?>>8)."\n"; } + + die $send_error if $send_error; } else { run_command([$send, @cstream, $recv], logfunc => $match_volid_and_log); } -- 2.20.1