From 8f4b8917d23b42d15b7f48eb3f814a56cc5a4343 Mon Sep 17 00:00:00 2001 From: Runar Borge Date: Sun, 25 Nov 2018 21:45:36 +0100 Subject: 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) --- scripts/vyatta-dhcp-helper.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; } -- cgit v1.2.3