summaryrefslogtreecommitdiffstats
path: root/src/usr/local/www/status_dhcpv6_leases.php
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-07-08 11:47:36 -0300
committerRenato Botelho <renato@netgate.com>2016-07-08 11:47:36 -0300
commit1f9c2cb696f493aaaa3512f29c080b7e422b24f2 (patch)
tree440940756336377752a0992ed220ffcc05ffc584 /src/usr/local/www/status_dhcpv6_leases.php
parentd58612209b4f785ba6acfc3703c848287102c6ad (diff)
downloadpfsense-1f9c2cb696f493aaaa3512f29c080b7e422b24f2.zip
pfsense-1f9c2cb696f493aaaa3512f29c080b7e422b24f2.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.php19
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();
OpenPOWER on IntegriCloud