summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunar Borge <runar@borge.nu>2018-11-25 21:45:36 +0100
committerChristian Poessinger <christian@poessinger.com>2018-11-27 15:47:00 +0100
commitf95015ec976933baee5cfa643002fbef2b4a32fe (patch)
tree6d0a4bfad250aafcf5d104db45b46447f034d69c
parent1d3697154c0701fdc5fd96014e142fb4ed438743 (diff)
downloadvyatta-cfg-system-f95015ec976933baee5cfa643002fbef2b4a32fe.tar.gz
vyatta-cfg-system-f95015ec976933baee5cfa643002fbef2b4a32fe.zip
T1045: static route dhcp-interface: check for ip in response
Checks done to verify a dhcp-lease on the interface is updated to look for a ip-address like response from dhclient before returning an error. This fixes the error where a newline was enough to make the checks fail.. Updated to also make sure no newline is returned after the address to make sure commands using adresses from this script is not cut in half by the newline, and to be in line with the syntax on all errors. (no newline at the end) (cherry picked from commit 8f4b8917d23b42d15b7f48eb3f814a56cc5a4343)
-rw-r--r--scripts/vyatta-dhcp-helper.pl5
1 files changed, 4 insertions, 1 deletions
diff --git a/scripts/vyatta-dhcp-helper.pl b/scripts/vyatta-dhcp-helper.pl
index 6febbaf9..4b236503 100644
--- a/scripts/vyatta-dhcp-helper.pl
+++ b/scripts/vyatta-dhcp-helper.pl
@@ -22,9 +22,12 @@ sub get_dhcp_router {
my $router = `grep new_routers= $lease | cut -d"'" -f2`;
my @r = split(/,/, $router);
$router = $r[0];
- if ($router eq "") {
+ # Make sure the result looks like a IP
+ if ($router !~ /\d+\.\d+\.\d+\.\d+/) {
return "127.0.0.1";
}
+ # Remove trailing newlines
+ $router =~ s/\n$//;
return $router;
}