diff options
author | Chris Buechler <cmb@pfsense.org> | 2015-12-17 18:59:08 -0600 |
---|---|---|
committer | Chris Buechler <cmb@pfsense.org> | 2015-12-17 19:00:29 -0600 |
commit | 5e71234e381084de09ab1d42c2fb30c9e9d52fc2 (patch) | |
tree | 8649218b86a3d9780820cb4ddbb1fa1248a53987 | |
parent | 221424055a2b85b5b80961e28d20645bc9bc80a6 (diff) | |
download | pfsense-5e71234e381084de09ab1d42c2fb30c9e9d52fc2.zip pfsense-5e71234e381084de09ab1d42c2fb30c9e9d52fc2.tar.gz |
Flush zone's tables if its db must be reset to avoid leaving behind any table entries. Ticket #5622
-rw-r--r-- | src/etc/inc/captiveportal.inc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/etc/inc/captiveportal.inc b/src/etc/inc/captiveportal.inc index 5449d93..0730962 100644 --- a/src/etc/inc/captiveportal.inc +++ b/src/etc/inc/captiveportal.inc @@ -1392,7 +1392,7 @@ function radius($username, $password, $clientip, $clientmac, $type, $radiusctx = } 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 (" . @@ -1441,6 +1441,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."); } |