Permalink
Browse files

Use cp instead of mv while saming old version of iptables, because th…

…is file could be a symlink!
  • Loading branch information...
1 parent ba98116 commit e782a473447fc0cad996f49ebb1f1553b786ace1 @DmitryKoterov committed Jan 9, 2013
Showing with 3 additions and 2 deletions.
  1. +3 −2 vzfirewall
View
@@ -3,7 +3,7 @@ use strict;
use File::Basename;
use POSIX 'strftime';
-my $VERSION = "1.04, 2010-03-04";
+my $VERSION = "1.05, 2013-01-09";
=head1
File /etc/sysconfig/vz-scripts/4.conf, FIREWALL directive
@@ -182,7 +182,8 @@ sub do_apply {
if (!close(P)) {
die "Test failed. Apply nothing.\n";
}
- rename($IPTABLES, $IPTABLES . ".bak." . strftime("%Y-%m-%d_%H-%M-%S", localtime(time)));
+ # Use cp instead of mv, because this file could be a symlink!
+ system("/bin/cp", $IPTABLES, $IPTABLES . ".bak." . strftime("%Y-%m-%d_%H-%M-%S", localtime(time)));
open(local *F, ">", $IPTABLES) or die "Cannot create $IPTABLES: $!\n";
print F $cmds;
close(F);

0 comments on commit e782a47

Please sign in to comment.