Skip to content

Commit 8f4b891

Browse files
committed
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)
1 parent c03bf34 commit 8f4b891

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

scripts/vyatta-dhcp-helper.pl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ sub get_dhcp_router {
2222
my $router = `grep new_routers= $lease | cut -d"'" -f2`;
2323
my @r = split(/,/, $router);
2424
$router = $r[0];
25-
if ($router eq "") {
25+
# Make sure the result looks like a IP
26+
if ($router !~ /\d+\.\d+\.\d+\.\d+/) {
2627
return "127.0.0.1";
2728
}
29+
# Remove trailing newlines
30+
$router =~ s/\n$//;
2831
return $router;
2932
}
3033

0 commit comments

Comments
 (0)