]>
git.proxmox.com Git - pve-firewall.git/blob - src/PVE/Firewall/Helpers.pm
1 package PVE
::Firewall
::Helpers
;
7 use PVE
::Tools
qw(file_get_contents file_set_contents);
16 my $pvefw_conf_dir = "/etc/pve/firewall";
19 my ($vmid, $timeout, $code, @param) = @_;
21 die "can't lock VM firewall config for undefined VMID\n"
24 my $res = PVE
::Cluster
::cfs_lock_firewall
("vm-$vmid", $timeout, $code, @param);
30 sub remove_vmfw_conf
{
33 my $vmfw_conffile = "$pvefw_conf_dir/$vmid.fw";
35 unlink $vmfw_conffile;
39 my ($vmid, $newid) = @_;
41 my $sourcevm_conffile = "$pvefw_conf_dir/$vmid.fw";
42 my $clonevm_conffile = "$pvefw_conf_dir/$newid.fw";
44 lock_vmfw_conf
($newid, 10, sub {
45 if (-f
$clonevm_conffile) {
46 unlink $clonevm_conffile;
48 if (-f
$sourcevm_conffile) {
49 my $data = file_get_contents
($sourcevm_conffile);
50 file_set_contents
($clonevm_conffile, $data);