From 99afee45aa3d41cd67ec5693354ec74cfb50cf48 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 19 Oct 2016 21:25:15 -0700 Subject: [PATCH] If host entered is 12 hex bytes in any format, convert to standard format --- dhcpd/lookup_host.cgi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dhcpd/lookup_host.cgi b/dhcpd/lookup_host.cgi index c4a2c35ee..5116c0f79 100755 --- a/dhcpd/lookup_host.cgi +++ b/dhcpd/lookup_host.cgi @@ -11,6 +11,13 @@ $in{'host'} || &error($text{'lookup_ehostname'}); $conf = &get_config(); @hosts = &find_recursive("host", $conf); +# Check to see if the host contains 6 hex bytes for a Mac address +(my $justbytes = $in{'host'}) =~ s/[^A-Fa-f0-9]//g; +if ($justbytes =~ /^[0-9a-f]{12}$/i) { + # Treat this host as a mac address with arbitrary formatting + $in{'host'} = join(':', unpack("(A2)*", $justbytes) ); +} + # Look for a match %access = &get_module_acl(); foreach $h (@hosts) {