diff options
author | Chris Buechler <cmb@pfsense.org> | 2015-12-17 18:59:08 -0600 |
---|---|---|
committer | Chris Buechler <cmb@pfsense.org> | 2015-12-17 18:59:08 -0600 |
commit | 07917f7df529dab51e8f6f6d346f5c7610972639 (patch) | |
tree | 2d862e2ca789d20064df476cd8ceffbfdc16caca | |
parent | 75272760ed970ade55881f4d3dc166783c553494 (diff) | |
download | pfsense-07917f7df529dab51e8f6f6d346f5c7610972639.zip pfsense-07917f7df529dab51e8f6f6d346f5c7610972639.tar.gz |
Flush zone's tables if its db must be reset to avoid leaving behind any table entries. Ticket #5622
-rw-r--r-- | etc/inc/captiveportal.inc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc index 5e834ca..0236ac9 100644 --- a/etc/inc/captiveportal.inc +++ b/etc/inc/captiveportal.inc @@ -1326,7 +1326,7 @@ function radius($username,$password,$clientip,$clientmac,$type, $radiusctx = nul } function captiveportal_opendb() { - global $g, $cpzone; + global $g, $config, $cpzone, $cpzoneid; $db_path = "{$g['vardb_path']}/captiveportal{$cpzone}.db"; $createquery = "CREATE TABLE IF NOT EXISTS captiveportal (" . @@ -1375,6 +1375,19 @@ function captiveportal_opendb() { $DB->busyTimeout(60000); if ($DB->exec($createquery)) { captiveportal_syslog("Successfully reinitialized tables for {$cpzone} -- database has been reset."); + if (!is_numericint($cpzoneid)) { + if (is_array($config['captiveportal'])) { + foreach ($config['captiveportal'] as $cpkey => $cp) { + if ($cpzone == $cp['zone']) { + $cpzoneid = $cp['zoneid']; + } + } + } + } + if (is_numericint($cpzoneid)) { + mwexec("/sbin/ipfw -x $cpzoneid table all flush"); + captiveportal_syslog("Flushed tables for {$cpzone} after database reset."); + } } else { captiveportal_syslog("Still unable to create tables for {$cpzone}. Error message: {$DB->lastErrorMsg()}. Remove the database file manually and try again."); } |