mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-19 19:22:14 +02:00
sqlite3 databases: check that the file exists and is writeable
This commit is contained in:
parent
92d6259cd0
commit
ceae3caa37
@ -1484,7 +1484,19 @@ function db_connect_with_errors() {
|
||||
$queries[] = 'SET CHARACTER SET utf8';
|
||||
$queries[] = "SET COLLATION_CONNECTION='utf8_general_ci'";
|
||||
} elseif (db_sqlite()) {
|
||||
$dsn = "sqlite:{$CONF['database_name']}";
|
||||
$db = $CONF['database_name'];
|
||||
|
||||
if (!file_exists($db)) {
|
||||
$error_text = 'SQLite database missing: '. $db;
|
||||
return array($link, $error_text);
|
||||
}
|
||||
|
||||
if (!is_writeable($db)) {
|
||||
$error_text = 'SQLite database not writeable: '. $db;
|
||||
return array($link, $error_text);
|
||||
}
|
||||
|
||||
$dsn = "sqlite:{$db}";
|
||||
$username_password = false;
|
||||
} elseif (db_pgsql()) {
|
||||
if (!isset($CONF['database_port'])) {
|
||||
@ -1509,7 +1521,6 @@ function db_connect_with_errors() {
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$error_text = 'PDO exception: '. $e->getMessage();
|
||||
error_log($error_text);
|
||||
}
|
||||
|
||||
return array($link, $error_text);
|
||||
|
Loading…
Reference in New Issue
Block a user