From 0d16b2820a43167a42409caa713c25e774f8b957 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Fri, 6 May 2016 13:28:22 -0700 Subject: [PATCH] Use 'date' format for compiletime rather than localtime format Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/ARP.pm | 4 ++-- Shorewall/Perl/Shorewall/Chains.pm | 6 +++--- Shorewall/Perl/Shorewall/Compiler.pm | 4 ++-- Shorewall/Perl/Shorewall/Config.pm | 12 ++++++++++++ Shorewall/Perl/Shorewall/Misc.pm | 6 +++--- Shorewall/Perl/Shorewall/Raw.pm | 2 +- Shorewall/Perl/Shorewall/Tc.pm | 4 ++-- 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Shorewall/Perl/Shorewall/ARP.pm b/Shorewall/Perl/Shorewall/ARP.pm index b0afab2d6..160c1c74c 100644 --- a/Shorewall/Perl/Shorewall/ARP.pm +++ b/Shorewall/Perl/Shorewall/ARP.pm @@ -244,7 +244,7 @@ sub create_arptables_load( $ ) { emit "exec 3>\${VARDIR}/.arptables-input"; - my $date = localtime; + my $date = compiletime; unless ( $test ) { emit_unindented '#'; @@ -294,7 +294,7 @@ sub create_arptables_load( $ ) { # sub preview_arptables_load() { - my $date = localtime; + my $date = compiletime; print "#\n# Generated by Shorewall $globals{VERSION} - $date\n#\n"; diff --git a/Shorewall/Perl/Shorewall/Chains.pm b/Shorewall/Perl/Shorewall/Chains.pm index 5b52f6560..e9da4fa43 100644 --- a/Shorewall/Perl/Shorewall/Chains.pm +++ b/Shorewall/Perl/Shorewall/Chains.pm @@ -8575,7 +8575,7 @@ sub create_netfilter_load( $ ) { enter_cat_mode; - my $date = localtime; + my $date = compiletime; unless ( $test ) { emit_unindented '#'; @@ -8683,7 +8683,7 @@ sub preview_netfilter_load() { enter_cat_mode1; - my $date = localtime; + my $date = compiletime; print "#\n# Generated by Shorewall $globals{VERSION} - $date\n#\n"; @@ -8919,7 +8919,7 @@ sub create_stop_load( $ ) { enter_cat_mode; unless ( $test ) { - my $date = localtime; + my $date = compiletime; emit_unindented '#'; emit_unindented "# Generated by Shorewall $globals{VERSION} - $date"; emit_unindented '#'; diff --git a/Shorewall/Perl/Shorewall/Compiler.pm b/Shorewall/Perl/Shorewall/Compiler.pm index b9a47d549..2248c95ea 100644 --- a/Shorewall/Perl/Shorewall/Compiler.pm +++ b/Shorewall/Perl/Shorewall/Compiler.pm @@ -90,7 +90,7 @@ sub generate_script_1( $ ) { if ( $test ) { emit "#!$config{SHOREWALL_SHELL}\n#\n# Compiled firewall script generated by Shorewall-perl\n#"; } else { - my $date = localtime; + my $date = compiletime; emit "#!$config{SHOREWALL_SHELL}\n#\n# Compiled firewall script generated by Shorewall $globals{VERSION} - $date\n#"; @@ -600,7 +600,7 @@ EOF # Generate info_command() # sub compile_info_command() { - my $date = localtime; + my $date = compiletime; emit( "\n", "#", diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index 4932468f5..db6bc448d 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -84,6 +84,8 @@ our @EXPORT = qw( require_capability report_used_capabilities kernel_version + + compiletime ); our @EXPORT_OK = qw( $shorewall_dir initialize shorewall); @@ -681,6 +683,8 @@ our %ipsets; # All required IPsets # our %filecache; +our $compiletime; + sub process_shorewallrc($$); sub add_variables( \% ); # @@ -1172,6 +1176,10 @@ sub initialize( $;$$) { %shorewallrc1 = %shorewallrc unless $shorewallrc1; add_variables %shorewallrc1; + + $compiletime = `date`; + + chomp $compiletime; } my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); @@ -1184,6 +1192,10 @@ sub all_ipsets() { sort keys %ipsets; } +sub compiletime() { + $compiletime; +} + # # Create 'currentlineinfo' # diff --git a/Shorewall/Perl/Shorewall/Misc.pm b/Shorewall/Perl/Shorewall/Misc.pm index c291410c2..2ce438828 100644 --- a/Shorewall/Perl/Shorewall/Misc.pm +++ b/Shorewall/Perl/Shorewall/Misc.pm @@ -302,7 +302,7 @@ sub convert_blacklist() { if ( @rules ) { my $fn1 = find_writable_file( 'blrules' ); my $blrules; - my $date = localtime; + my $date = compiletime; if ( -f $fn1 ) { open $blrules, '>>', $fn1 or fatal_error "Unable to open $fn1: $!"; @@ -393,7 +393,7 @@ sub convert_routestopped() { my ( @allhosts, %source, %dest , %notrack, @rule ); my $seq = 0; - my $date = localtime; + my $date = compiletime; my ( $stoppedrules, $fn1 ); @@ -421,7 +421,7 @@ EOF first_entry( sub { - my $date = localtime; + my $date = compiletime; progress_message2 "$doing $fn..."; print( $stoppedrules "#\n" , diff --git a/Shorewall/Perl/Shorewall/Raw.pm b/Shorewall/Perl/Shorewall/Raw.pm index 34b51a23e..6e66178a8 100644 --- a/Shorewall/Perl/Shorewall/Raw.pm +++ b/Shorewall/Perl/Shorewall/Raw.pm @@ -368,7 +368,7 @@ sub setup_conntrack($) { if ( $convert ) { my $conntrack; my $empty = 1; - my $date = localtime; + my $date = compiletime; if ( $fn ) { open $conntrack, '>>', $fn or fatal_error "Unable to open $fn for notrack conversion: $!"; diff --git a/Shorewall/Perl/Shorewall/Tc.pm b/Shorewall/Perl/Shorewall/Tc.pm index 171618021..c3f4969d5 100644 --- a/Shorewall/Perl/Shorewall/Tc.pm +++ b/Shorewall/Perl/Shorewall/Tc.pm @@ -2166,7 +2166,7 @@ sub convert_tos($$) { if ( my $fn = open_file 'tos' ) { first_entry( sub { - my $date = localtime; + my $date = compiletime; progress_message2 "Converting $fn..."; print( $mangle "#\n" , @@ -2332,7 +2332,7 @@ sub setup_tc( $ ) { first_entry( sub { - my $date = localtime; + my $date = compiletime; progress_message2 "Converting $fn..."; print( $mangle "#\n" ,