From 9b9d2caa72639479309bc6e19dc811cc8aeaf384 Mon Sep 17 00:00:00 2001 From: erkin Date: Thu, 16 Dec 2021 18:57:45 +0300 Subject: remote: Cleanly handle the case of no source address --- scripts/vyatta-commit-push.pl | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/scripts/vyatta-commit-push.pl b/scripts/vyatta-commit-push.pl index d5637ca..6e5752b 100755 --- a/scripts/vyatta-commit-push.pl +++ b/scripts/vyatta-commit-push.pl @@ -73,13 +73,9 @@ my $source_address = $config->returnEffectiveValue('source-address'); # If so, we're going to pass that to the Python funcall. if (defined($source_address)) { print("Using source address $source_address\n"); - # The string needs to be wrapped in quotes. - $source_address = '"' . $source_address . '"'; -} -# Otherwise, we're going to pass None. -else { - $source_address = "None"; } +# The string needs to be wrapped in quotes, even if it's empty. +$source_address = '"' . $source_address . '"'; print "Archiving config...\n"; foreach my $uri (@uris) { @@ -97,12 +93,7 @@ foreach my $uri (@uris) { $remote .= "$path" if defined $path; print " $remote "; - # Don't set var 'source_host' if 'source-address' not in configuration - if ($source_address eq "None") { - system("python3 -c 'from vyos.remote import upload; upload(\"$tmp_push_file\", \"$uri/$save_file\")'"); - } else { - system("python3 -c 'from vyos.remote import upload; upload(\"$tmp_push_file\", \"$uri/$save_file\", source_host=$source_address)'"); - } + system("python3 -c 'from vyos.remote import upload; upload(\"$tmp_push_file\", \"$uri/$save_file\", source_host=$source_address)'"); } move($tmp_push_file, $last_push_file); -- cgit v1.2.3