diff options
author | Renato Botelho <renato@netgate.com> | 2016-07-08 11:47:36 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-07-08 11:47:47 -0300 |
commit | 8f867225f4c2d3e61863f8d87d4ddb4143d5dda6 (patch) | |
tree | e23b73cb1e4d0821141d167b84ed9b4315c6ca6c /src/usr/local/www/status_dhcpv6_leases.php | |
parent | 65231ec53753af000bb05ef16d214672086a8c1e (diff) | |
download | pfsense-8f867225f4c2d3e61863f8d87d4ddb4143d5dda6.zip pfsense-8f867225f4c2d3e61863f8d87d4ddb4143d5dda6.tar.gz |
Improve patterns to read dhcpd6.leases to prevent leases containing '}' in ia-na line not showing up. It fixes #6543
Diffstat (limited to 'src/usr/local/www/status_dhcpv6_leases.php')
-rw-r--r-- | src/usr/local/www/status_dhcpv6_leases.php | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/usr/local/www/status_dhcpv6_leases.php b/src/usr/local/www/status_dhcpv6_leases.php index 2392f48..d4e1933 100644 --- a/src/usr/local/www/status_dhcpv6_leases.php +++ b/src/usr/local/www/status_dhcpv6_leases.php @@ -180,14 +180,23 @@ function parse_duid($duid_string) { } $awk = "/usr/bin/awk"; +$sed = "/usr/bin/sed"; + +/* Remove all lines except ia-.. blocks */ +$cleanpattern = "'/^ia-.. /, /^}/ !d; s,;$,,; s, *, ,g'"; +/* | | | + * | | | + * | | -> Remove extra spaces + * | -> Remove ; from EOL + * -> Delete all lines except blocks that start with ia-.. + * and end with } + */ -/* this pattern sticks comments into a single array item */ -$cleanpattern = "'{ gsub(\"^#.*\", \"\");} { gsub(\"^server-duid.*\", \"\");} { gsub(\";$\", \"\"); print;}'"; -/* We then split the leases file by } */ -$splitpattern = "'BEGIN { RS=\"}\";} {for (i=1; i<=NF; i++) printf \"%s \", \$i; printf \"}\\n\";}'"; +/* Join each block in single line */ +$splitpattern = "'{printf $0}; $0 ~ /^\}/ {printf \"\\n\"}'"; /* stuff the leases file in a proper format into a array by line */ -exec("/bin/cat {$leasesfile} | {$awk} {$cleanpattern} | {$awk} {$splitpattern} | /usr/bin/grep '^ia-.. '", $leases_content); +exec("{$sed} {$cleanpattern} {$leasesfile} | {$awk} {$splitpattern}", $leases_content); $leases_count = count($leases_content); exec("/usr/sbin/ndp -an", $rawdata); $ndpdata = array(); |