summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2015-07-30 10:42:21 -0400
committerjim-p <jimp@pfsense.org>2015-07-30 10:42:21 -0400
commit7c38032f065c953c5c61a46204d8bceb02f881d8 (patch)
tree8ce24abf37fa4bb3c266e6ba9ae144f229355ec4
parent79e46ebda9eb3b92fc911fd82ef3b701ef3a64da (diff)
downloadpfsense-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.
-rw-r--r--etc/inc/captiveportal.inc10
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.");
OpenPOWER on IntegriCloud