luci-base: fix parsing of ethers(5)
The /etc/ethers file may contain any number of white space characters between the mac address and the IP/hostname field, so extend the pattern to allow for that. Man ethers(5) also states that the IP field may be a symbolic hostname, so test whether the name is an IP address or hostname before adding it to the hints structure. Fixes #1674. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
bf04031171
commit
62630fbf88
1 changed files with 7 additions and 3 deletions
|
@ -146,9 +146,13 @@ local function _nethints(what, callback)
|
||||||
|
|
||||||
if fs.access("/etc/ethers") then
|
if fs.access("/etc/ethers") then
|
||||||
for e in io.lines("/etc/ethers") do
|
for e in io.lines("/etc/ethers") do
|
||||||
mac, ip = e:match("^([a-f0-9]%S+) (%S+)")
|
mac, name = e:match("^([a-fA-F0-9:]+)%s+(%S+)")
|
||||||
if mac and ip then
|
if mac and name then
|
||||||
_add(what, mac:upper(), ip, nil, nil)
|
if luci.ip.IPv4(name) then
|
||||||
|
_add(what, mac:upper(), name, nil, nil)
|
||||||
|
else
|
||||||
|
_add(what, mac:upper(), nil, nil, name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue