Correct update inline

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2013-12-15 09:32:09 -08:00
parent cb74b2d706
commit 6d72cb3138
2 changed files with 19 additions and 16 deletions

View File

@ -3506,8 +3506,8 @@ shorewall_cli() {
g_conditional= g_conditional=
g_file= g_file=
g_doing="Compiling" g_doing="Compiling"
g_directives g_directives=
g_inline g_inline=
VERBOSE= VERBOSE=
VERBOSITY=1 VERBOSITY=1

View File

@ -5201,11 +5201,12 @@ if ( /^\\s*COMMENT\\s+/ ) {
s/COMMENT/?COMMENT/; s/COMMENT/?COMMENT/;
} }
unless ( /^\\s*INLINE[( \\t]/ ) { perl -pi.bak -e '
if ( /^(.+?);(\\s*.*?)(\\s*#.*)?$/ ) { unless ( /^\\s*INLINE[( \\t:]/ || /^\\s*#/ ) {
$_ = "$1\\{$2 \\}"; if ( /^(.+?);(\\s*.+?)(\\s*#.*)?\$/ ) {
$_ .= $3 if defined $3 && $2 ne ""; \$_ = "\$1\\{\$2 \\}";
$_ .= "\\n"; \$_ .= \$3 if defined \$3 && \$3 ne "";
\$_ .= "\\n";
} }
}' $file }' $file
EOF EOF
@ -5220,7 +5221,7 @@ EOF
warning message "Unable to rename ${file}.bak to $file:$!"; warning message "Unable to rename ${file}.bak to $file:$!";
} }
} else { } else {
warning_message ("Unable to update file ${file}.bak:$!" ); warning_message ("Unable to update file $file" );
} }
} else { } else {
warning_message( "$file skipped (not writeable)" ) unless -d _; warning_message( "$file skipped (not writeable)" ) unless -d _;
@ -5270,13 +5271,15 @@ sub convert_alternative_format() {
# #
# writeable regular file # writeable regular file
# #
print "Updating $file...\n";
my $result = system << "EOF"; my $result = system << "EOF";
perl -pi.bak -e ' perl -pi.bak -e '
unless ( /^\\s*INLINE[( \\t]/ ) { unless ( /^\\s*INLINE[( \\t:]/ || /^\\s*#/ ) {
if ( /^(.+?);(\\s*.*?)(\\s*#.*)?$/ ) { if ( /^(.+?);(\\s*.+?)(\\s*#.*)?\$/ ) {
$_ = "$1\\{$2 \\}"; \$_ = "\$1\\{\$2 \\}";
$_ .= $3 if defined $3 && $2 ne ""; \$_ .= \$3 if defined \$3 && \$3 ne "";
$_ .= "\\n"; \$_ .= "\\n";
} }
}' $file }' $file
EOF EOF
@ -5289,7 +5292,7 @@ EOF
warning message "Unable to rename ${file}.bak to $file:$!"; warning message "Unable to rename ${file}.bak to $file:$!";
} }
} else { } else {
warning_message ("Unable to update file ${file}.bak:$!" ); warning_message ("Unable to update file $file" );
} }
} else { } else {
warning_message( "$file skipped (not writeable)" ) unless -d _; warning_message( "$file skipped (not writeable)" ) unless -d _;
@ -5323,7 +5326,7 @@ sub get_configuration( $$$$$ ) {
get_params; get_params;
process_shorewall_conf( $update, $annotate, $directives ); process_shorewall_conf( $update, $annotate, $directives || $inline );
ensure_config_path; ensure_config_path;
@ -5994,7 +5997,7 @@ sub get_configuration( $$$$$ ) {
if ( $directives ) { if ( $directives ) {
convert_to_directives(0); convert_to_directives(0);
} else { } elsif ( $inline ) {
convert_alternative_format; convert_alternative_format;
} }