From 5c95e48479d33dc1c821d7eaa0774a1a94b278f7 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 9 Jun 2016 16:54:49 +0200 Subject: [PATCH] Dir storage creation: check for a sane path Ideally we don't need this, but this with the directory storage this is a user-input field which gets returned by the storage's path() method which is used in various external command calls. --- PVE/Storage/DirPlugin.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/PVE/Storage/DirPlugin.pm b/PVE/Storage/DirPlugin.pm index 23cb6bb..ab9e4bd 100644 --- a/PVE/Storage/DirPlugin.pm +++ b/PVE/Storage/DirPlugin.pm @@ -62,5 +62,14 @@ sub activate_storage { $class->SUPER::activate_storage($storeid, $scfg, $cache); } +sub check_config { + my ($self, $sectionId, $config, $create, $skipSchemaCheck) = @_; + my $opts = PVE::SectionConfig::check_config($self, $sectionId, $config, $create, $skipSchemaCheck); + return $opts if !$create; + if ($opts->{path} !~ m@^/[-/a-zA-Z0-9_.]+$@) { + die "illegal path for directory storage: $opts->{path}\n"; + } + return $opts; +} 1;