Fix COMMENT rule generation -- Take 2

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@6304 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2007-05-09 17:30:28 +00:00
parent c83727b516
commit 9fe1d8e260

View File

@ -328,20 +328,12 @@ sub add_rule($$)
{ {
my ($chainref, $rule) = @_; my ($chainref, $rule) = @_;
$rule .= " -m comment --comment \"$comment\"" if $comment;
if ( $chainref->{loopcount} || $chainref->{cmdcount} ) { if ( $chainref->{loopcount} || $chainref->{cmdcount} ) {
# $rule .= " -m comment --comment \\\"$comment\\\"" if $comment;
# The shell has this wonderful habit of removing quote marks. Certain rule constructs such
# as --comment and --log-prefix quote the associated value. The following statement
# will add an escape to each double quote in the rule so that when the rule is finally
# written to the iptables-input file, it will still have quote marks.
#
$rule =~ s/"/\\"/g;
add_command $chainref , qq(echo "-A $chainref->{name} $rule" >&3); add_command $chainref , qq(echo "-A $chainref->{name} $rule" >&3);
} else { } else {
$rule .= " -m comment --comment \"$comment\"" if $comment;
push @{$chainref->{rules}}, $rule; push @{$chainref->{rules}}, $rule;
$chainref->{referenced} = 1; $chainref->{referenced} = 1;
} }
@ -1198,10 +1190,22 @@ sub log_rule_limit( $$$$$$$$ ) {
warning_message "Log Prefix shortened to \"$prefix\""; warning_message "Log Prefix shortened to \"$prefix\"";
} }
if ( $level eq 'ULOG' ) { if ( $chainref->{loopcount} || $chainref->{cmdcount} ) {
$prefix = "-j ULOG $globals{LOGPARMS}--ulog-prefix \"$prefix\" "; #
# The rule will be converted to an "echo" shell command. We must insure that the
# quotes are preserved in the iptables-input file.
#
if ( $level eq 'ULOG' ) {
$prefix = "-j ULOG $globals{LOGPARMS}--ulog-prefix \\\"$prefix\\\" ";
} else {
$prefix = "-j LOG $globals{LOGPARMS}--log-level $level --log-prefix \\\"$prefix\\\" ";
}
} else { } else {
$prefix = "-j LOG $globals{LOGPARMS}--log-level $level --log-prefix \"$prefix\" "; if ( $level eq 'ULOG' ) {
$prefix = "-j ULOG $globals{LOGPARMS}--ulog-prefix \"$prefix\" ";
} else {
$prefix = "-j LOG $globals{LOGPARMS}--log-level $level --log-prefix \"$prefix\" ";
}
} }
if ( $command eq 'add' ) { if ( $command eq 'add' ) {