From 16ff09f72c6271aa7aef98d581e59a6833ae37d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Mon, 4 Nov 2024 11:42:19 +0100 Subject: [PATCH] storage tunnel: check just-imported image files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit remote migration requires elevated privileges already and can thus only be triggered by trusted sources, but an additional safeguard of checking the image for external references doesn't hurt. Signed-off-by: Fabian Grünbichler --- src/PVE/StorageTunnel.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/PVE/StorageTunnel.pm b/src/PVE/StorageTunnel.pm index c880889..fa7889c 100644 --- a/src/PVE/StorageTunnel.pm +++ b/src/PVE/StorageTunnel.pm @@ -280,6 +280,14 @@ sub handle_query_disk_import { delete $state->{sockets}->{$unix}; delete $state->{disk_import}; $state->{cleanup}->{volumes}->{$volid} = 1; + my $cfg = PVE::Storage::config(); + my ($storage, $volume) = PVE::Storage::parse_volume_id($volid); + my $scfg = PVE::Storage::storage_config($cfg, $storage); + # check imported image for bad references + if ($scfg->{path}) { + my $path = PVE::Storage::path($cfg, $volid); + PVE::Storage::file_size_info($path, undef, 1); + } return { status => "complete", volid => $volid,