diff options
author | Olivier Blin <blino@mageia.org> | 2011-12-02 23:07:16 +0000 |
---|---|---|
committer | Olivier Blin <blino@mageia.org> | 2011-12-02 23:07:16 +0000 |
commit | d3ef88e2e95a28f224c0b5d4b441339313ed2a66 (patch) | |
tree | 019e298b50703ec4a7a259fffd482d49f02b850c | |
parent | 4f67c571f7a6e4f730cdb9766bbe9983de0e3965 (diff) | |
download | drakx-net-d3ef88e2e95a28f224c0b5d4b441339313ed2a66.tar drakx-net-d3ef88e2e95a28f224c0b5d4b441339313ed2a66.tar.gz drakx-net-d3ef88e2e95a28f224c0b5d4b441339313ed2a66.tar.bz2 drakx-net-d3ef88e2e95a28f224c0b5d4b441339313ed2a66.tar.xz drakx-net-d3ef88e2e95a28f224c0b5d4b441339313ed2a66.zip |
do not write end line twice in shorewall files if there is no "LAST LINE" marker
-rw-r--r-- | lib/network/shorewall.pm | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/network/shorewall.pm b/lib/network/shorewall.pm index 46bafed..f07edf3 100644 --- a/lib/network/shorewall.pm +++ b/lib/network/shorewall.pm @@ -22,8 +22,10 @@ sub set_config_file { my $done; substInFile { - if (!$done && (/^#LAST LINE/ || eof)) { - $_ = join('', map { join("\t", @$_) . "\n" } @l) . $_; + my $last_line = /^#LAST LINE/ && $_; + if (!$done && ($last_line || eof)) { + $_ = join('', map { join("\t", @$_) . "\n" } @l); + $_ .= $last_line if $last_line; $done = 1; } else { $_ = '' if /^[^#]/; @@ -40,9 +42,11 @@ sub set_in_file { my ($file, $enabled, @list) = @_; my $done; substInFile { + my $last_line = /^#LAST LINE/ && $_; foreach my $l (@list) { s|^$l\n|| } - if (!$done && $enabled && (/^#LAST LINE/ || eof)) { - $_ = join('', map { "$_\n" } @list) . $_; + if (!$done && $enabled && ($last_line || eof)) { + $_ = join('', map { "$_\n" } @list); + $_ .= $last_line if $last_line; $done = 1; } } "$::prefix/etc/shorewall/$file"; |