use chattr to set immutable flag on base images

This commit is contained in:
Dietmar Maurer
2013-01-31 11:52:31 +01:00
parent a7f3d90919
commit c803c3963c

View File

@ -449,8 +449,14 @@ sub create_base {
rename($path, $newpath) || rename($path, $newpath) ||
die "rename '$path' to '$newpath' failed - $!\n"; 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; return $newvolname;
} }
@ -575,9 +581,13 @@ sub free_image {
"(use by '$tmpvolname')\n"; "(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; return undef;
} }