diff options
author | jim-p <jimp@pfsense.org> | 2015-07-30 10:42:21 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2015-07-30 10:42:21 -0400 |
commit | 7c38032f065c953c5c61a46204d8bceb02f881d8 (patch) | |
tree | 8ce24abf37fa4bb3c266e6ba9ae144f229355ec4 /etc/inc | |
parent | 79e46ebda9eb3b92fc911fd82ef3b701ef3a64da (diff) | |
download | pfsense-7c38032f065c953c5c61a46204d8bceb02f881d8.zip pfsense-7c38032f065c953c5c61a46204d8bceb02f881d8.tar.gz |
Take more care when attempting to open the CP database. Don't assume it's valid before attempting to use it.
Diffstat (limited to 'etc/inc')
-rw-r--r-- | etc/inc/captiveportal.inc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc index dd4f35a..460263d 100644 --- a/etc/inc/captiveportal.inc +++ b/etc/inc/captiveportal.inc @@ -1415,6 +1415,16 @@ function captiveportal_opendb() { "CREATE INDEX IF NOT EXISTS starttime ON captiveportal (allow_time)"; $DB = new SQLite3($db_path); + if (!$DB) { + captiveportal_syslog("Could not open {$db_path} as an sqlite database for {$cpzone}. Error message: {$DB->lastErrorMsg()}. Trying again."); + unlink_if_exists($db_path); + $DB = new SQLite3($db_path); + if (!$DB) { + captiveportal_syslog("Still could not open {$db_path} as an sqlite database for {$cpzone}. Error message: {$DB->lastErrorMsg()}. Remove the database file manually and ensure there is enough free space."); + return; + } + } + if (! $DB->exec($createquery)) { captiveportal_syslog("Error during table {$cpzone} creation. Error message: {$DB->lastErrorMsg()}. Resetting and trying again."); |