From 6d72cb31382bfaf737c95d3e9e3a3dac4fe0801c Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sun, 15 Dec 2013 09:32:09 -0800 Subject: [PATCH] Correct update inline Signed-off-by: Tom Eastep --- Shorewall-core/lib.cli | 4 ++-- Shorewall/Perl/Shorewall/Config.pm | 31 ++++++++++++++++-------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Shorewall-core/lib.cli b/Shorewall-core/lib.cli index 4d4e4e4fe..7c856cbf7 100644 --- a/Shorewall-core/lib.cli +++ b/Shorewall-core/lib.cli @@ -3506,8 +3506,8 @@ shorewall_cli() { g_conditional= g_file= g_doing="Compiling" - g_directives - g_inline + g_directives= + g_inline= VERBOSE= VERBOSITY=1 diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index dfde0d0f4..3878cb987 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -5201,11 +5201,12 @@ if ( /^\\s*COMMENT\\s+/ ) { s/COMMENT/?COMMENT/; } -unless ( /^\\s*INLINE[( \\t]/ ) { - if ( /^(.+?);(\\s*.*?)(\\s*#.*)?$/ ) { - $_ = "$1\\{$2 \\}"; - $_ .= $3 if defined $3 && $2 ne ""; - $_ .= "\\n"; +perl -pi.bak -e ' +unless ( /^\\s*INLINE[( \\t:]/ || /^\\s*#/ ) { + if ( /^(.+?);(\\s*.+?)(\\s*#.*)?\$/ ) { + \$_ = "\$1\\{\$2 \\}"; + \$_ .= \$3 if defined \$3 && \$3 ne ""; + \$_ .= "\\n"; } }' $file EOF @@ -5220,7 +5221,7 @@ EOF warning message "Unable to rename ${file}.bak to $file:$!"; } } else { - warning_message ("Unable to update file ${file}.bak:$!" ); + warning_message ("Unable to update file $file" ); } } else { warning_message( "$file skipped (not writeable)" ) unless -d _; @@ -5270,13 +5271,15 @@ sub convert_alternative_format() { # # writeable regular file # + print "Updating $file...\n"; + my $result = system << "EOF"; perl -pi.bak -e ' -unless ( /^\\s*INLINE[( \\t]/ ) { - if ( /^(.+?);(\\s*.*?)(\\s*#.*)?$/ ) { - $_ = "$1\\{$2 \\}"; - $_ .= $3 if defined $3 && $2 ne ""; - $_ .= "\\n"; +unless ( /^\\s*INLINE[( \\t:]/ || /^\\s*#/ ) { + if ( /^(.+?);(\\s*.+?)(\\s*#.*)?\$/ ) { + \$_ = "\$1\\{\$2 \\}"; + \$_ .= \$3 if defined \$3 && \$3 ne ""; + \$_ .= "\\n"; } }' $file EOF @@ -5289,7 +5292,7 @@ EOF warning message "Unable to rename ${file}.bak to $file:$!"; } } else { - warning_message ("Unable to update file ${file}.bak:$!" ); + warning_message ("Unable to update file $file" ); } } else { warning_message( "$file skipped (not writeable)" ) unless -d _; @@ -5323,7 +5326,7 @@ sub get_configuration( $$$$$ ) { get_params; - process_shorewall_conf( $update, $annotate, $directives ); + process_shorewall_conf( $update, $annotate, $directives || $inline ); ensure_config_path; @@ -5994,7 +5997,7 @@ sub get_configuration( $$$$$ ) { if ( $directives ) { convert_to_directives(0); - } else { + } elsif ( $inline ) { convert_alternative_format; }