From c803c3963cfe791eff1a82c10972002a09c57f93 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 31 Jan 2013 11:52:31 +0100 Subject: [PATCH] use chattr to set immutable flag on base images --- PVE/Storage/Plugin.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index 0cbf488..9545626 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -449,8 +449,14 @@ sub create_base { rename($path, $newpath) || die "rename '$path' to '$newpath' failed - $!\n"; - chmod(0444, $newpath); + # We try to protect base volume + chmod(0444, $newpath); # nobody should write anything + + # also try to set immutable flag + eval { run_command(['/usr/bin/chattr', '+i', $newpath]); }; + warn $@ if $@; + return $newvolname; } @@ -575,9 +581,13 @@ sub free_image { "(use by '$tmpvolname')\n"; } } + + # try to remove immutable flag + eval { run_command(['/usr/bin/chattr', '-i', $path]); }; + warn $@ if $@; } - unlink $path; + unlink($path) || die "unlink '$path' failed - $!\n"; return undef; } -- 2.39.2