[pve-devel] [PATCH guest-common v3 2/2] add check_hookscript_volume_id to GuestHelpers

Dominik Csapak d.csapak at proxmox.com
Tue Jan 29 16:28:42 CET 2019


this will be used for the container/vm api to check if the
hookscript volume id is correct

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
new in v3
 PVE/GuestHelpers.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/PVE/GuestHelpers.pm b/PVE/GuestHelpers.pm
index 8327dcb..5a8fdd6 100644
--- a/PVE/GuestHelpers.pm
+++ b/PVE/GuestHelpers.pm
@@ -24,6 +24,21 @@ sub guest_migration_lock {
     return $res;
 }
 
+sub check_hookscript_volume_id {
+    my ($volid, $storecfg) = @_;
+
+    my ($path, undef, $type) = PVE::Storage::path($storecfg, $volid);
+
+    die "'$volid' is not in the snippets directory\n"
+	if $type ne 'snippets';
+
+    die "script '$volid' does not exists\n"
+	if ! -f $path;
+
+    die "script '$volid' is not executable\n"
+	if ! -x $path;
+}
+
 sub exec_hookscript {
     my ($conf, $vmid, $phase, $stop_on_error) = @_;
 
-- 
2.11.0





More information about the pve-devel mailing list