Don't compute sha1 hash when testing

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2020-04-02 10:11:21 -07:00
parent 3f0e4959a1
commit e49f31fb42
No known key found for this signature in database
GPG Key ID: 96E6B3F2423A4D10
2 changed files with 14 additions and 12 deletions

View File

@ -913,7 +913,7 @@ sub compiler {
#
# Close, rename and secure the script
#
finalize_script ( $export );
finalize_script ( $export, $test );
#
# And generate the auxilary config file
#

View File

@ -2015,23 +2015,25 @@ sub generate_sha1() {
#
# Finalize the script file
#
sub finalize_script( $ ) {
my $export = $_[0];
sub finalize_script( $$ ) {
my ( $export, $test ) = @_;
close $script;
$script = 0;
if ( $file ne '-' ) {
my $sha1sum = generate_sha1;
my $sha1sum1 = join( '-', 'sha-lh', substr( $sha1sum, 0, 20 ) );
my $sha1sum2 = join( '-', 'sha-rh', substr( $sha1sum, -20 ) );
unless ( $test ) {
my $sha1sum = generate_sha1;
my $sha1sum1 = join( '-', 'sha-lh', substr( $sha1sum, 0, 20 ) );
my $sha1sum2 = join( '-', 'sha-rh', substr( $sha1sum, -20 ) );
@ARGV = ( $tempfile );
$^I = '';
@ARGV = ( $tempfile );
$^I = '';
while ( <> ) {
s/g_sha1sum1=/g_sha1sum1=$sha1sum1/;
s/g_sha1sum2=/g_sha1sum2=$sha1sum2/;
print;
while ( <> ) {
s/g_sha1sum1=/g_sha1sum1=$sha1sum1/;
s/g_sha1sum2=/g_sha1sum2=$sha1sum2/;
print;
}
}
rename $tempfile, $file or fatal_error "Cannot Rename $tempfile to $file: $!";