fix #4085: properly activate cicustom storage(s)

PVE::Storage::path() neither activates the storage of the passed-in volume, nor
does it ensure that the returned value is actually a file or block device, so
this actually fixes two issues. PVE::Storage::abs_filesystem_path() actually
takes care of both, while still calling path() under the hood (since $volid
here is always a proper volid, unless we change the cicustom schema at some
point in the future).

Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2024-01-25 13:33:12 +01:00
parent 629923d025
commit 9946d6fa57

View File

@ -550,8 +550,11 @@ sub get_custom_cloudinit_files {
sub read_cloudinit_snippets_file {
my ($storage_conf, $volid) = @_;
my ($full_path, undef, $type) = PVE::Storage::path($storage_conf, $volid);
die "$volid is not in the snippets directory\n" if $type ne 'snippets';
my ($vtype, undef) = PVE::Storage::parse_volname($storage_conf, $volid);
die "$volid is not in the snippets directory\n" if $vtype ne 'snippets';
my $full_path = PVE::Storage::abs_filesystem_path($storage_conf, $volid, 1);
return PVE::Tools::file_get_contents($full_path, 1 * 1024 * 1024);
}