Commit Graph
49 Commits
Author SHA1 Message Date
DL6ER ab50c5ccc4 Update SQLite from 3.30.0 to 3.30.1
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-10-11 17:49:12 +02:00
Mark Drobnak 65737e1f74 Merge pull request #650 from pi-hole/update/sqlite_3.30.0
Update SQLite from 3.29.0 to 3.30.0
2019-10-10 12:47:32 -04:00
DL6ER 5ab2a98c31 Don't finalize SQLite statement too early.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-10-10 17:30:14 +02:00
DL6ER bd60342ec3 Update SQLite from 3.29.0 to 3.30.0
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-10-10 17:06:06 +02:00
DL6ER 6f7b4ea82d Ensure to finalize statement before calling DELETE that might affect the running transaction. SQLite3 does not accept such a DELETE in a running statement.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-10-01 22:15:13 +02:00
DL6ER 9dd376b88a Harden network database upgrading procedure. We have at least one bug report that creating the unique index during the upgrade to database version 4 failed. We remove the addition of this unique index as it will anyway be dropped again a second later when upgrading to version 5. Meanwhile, we improve on the upgrading procedure to version 5 by implementing explicit conflict handling for duplicate ID<->IP and duplicate HWADDR entries.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-26 16:36:03 +02:00
DL6ER 12df978432 Do not try to bind to statements that might not be available when preparing the database failed.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-09-20 22:53:49 +02:00
DL6ER ca4ebdbb70 Merge pull request #621 from pi-hole/update/sqlite_3.29.0
Update contained SQLite from 3.28.0 to 3.29.0
2019-09-05 21:25:18 +02:00
DL6ER f3e8d23baf Merge branch 'development' into new/whitelist-regex-support
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-08-17 15:01:32 +02:00
DL6ER 2a731f08a3 Remove call to sqlite3_finalize(stmt) on error in gravityDB_getDomain(). We always finalize the statement afterwards - whether or not we encountered an error before.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-08-07 21:21:06 +02:00
DL6ER 35d543da44 Log error code returned when initializing the mutex fails.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-08-04 20:11:48 +02:00
DL6ER d0be1b59af Lock the thread during db_init(). Use dbclose() to close the database handle. It does not only include error checking, but also makes sure to unlock the thread.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-08-04 18:57:38 +02:00
DL6ER 894598e89d make sure we initilize the database mutex at the beginning of db_init() to ensure we always have the lock available.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-08-04 18:50:38 +02:00
DL6ER 0a78b27698 Merge pull request #624 from pi-hole/tweak/bbusy_timeouts
Add database busy timeouts
2019-07-21 22:15:03 +02:00
Mcat12 32f603d398 Fix accidental formatting change
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-07-21 13:01:05 -07:00
Mcat12 c07be92210 Remove dbquery macro in favor of just using the function
This avoids unused return value warnings.

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-07-21 12:57:56 -07:00
Mcat12 b2f9339db7 Add dbquery_ret for getting the DB return code from a query
Also change the ARP parsing to only warn if the database is busy, as it
executes each minute by default.

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-07-21 12:43:06 -07:00
DL6ER b21b551a52 Add busy timeout for database connections.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-21 21:43:03 +02:00
Mcat12 ab2bfcb167 Move SQL error logging from macros to dbquery
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-07-21 12:06:00 -07:00
Mcat12 7864480884 Fix failure during parse_neighbor_cache not unlocking shared memory
Also log the SQL statement that failed in the macro.

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-07-21 11:47:45 -07:00
DL6ER 6bee725b1c Update SQLite 3.28.0 -> 3.29.0
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-18 12:12:32 +02:00
DL6ER 8c6736a55f Fix minor typo.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-16 18:49:51 +02:00
DL6ER dd8af36613 Add debugging output for gravity table if requested via DEBUG_DATABASE option. We might want to separate this into DEBUG_GRAVITY_DATABASE in the future.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-16 12:25:42 +02:00
DL6ER a3f25f92f2 Do not check regex whitelist filters when querying the domain_audit table. Added documentation to in_whitelist() that explains the idea of the chosen implementation method.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-16 12:04:43 +02:00
DL6ER caf18e1370 Improve difference between between REGEX and TABLE constants by renaming the latter to always end in _TABLE. Also remove code duplication by using a lookup array for the table names instead of using multiple select labels.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-16 11:55:34 +02:00
DL6ER d362a5eb27 Merge branch 'development' into new/whitelist-regex-support
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-14 22:50:53 +02:00
Mark Drobnak 7671fe9e2e Merge pull request #608 from pi-hole/new/use_audit_database_table
Use database table for domain auditlog
2019-07-10 22:57:04 -04:00
DL6ER f996753dec Rename in_whitelist() to whitelisted() as this routine does not only compare against the whitelist table but also evaluates possible whitelist regex filters.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-09 17:48:27 +02:00
DL6ER c0eedd59db Rename table regex to regex_blacklist.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-08 21:12:43 +02:00
DL6ER d79891daaf New table is called regex_whitelist (at least for now).
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-07 22:52:23 +02:00
DL6ER fdff462fa4 Add support for regex filters for whitelisting.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-07 22:46:28 +02:00
DL6ER 8e0016e0bd Audit table has been renamed to domain_audit.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-07 21:24:47 +02:00
Mark Drobnak ac1018aa2a Merge pull request #610 from pi-hole/tweak/database_error_checking
Database error checking
2019-07-07 15:04:35 -04:00
DL6ER a5ea558d5a Merge branch 'new/modularize_headers' into new/use_audit_database_table
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-07 10:09:54 +02:00
DL6ER 5c75fc3e67 Move even more definitions from FTL.h into the respective headers.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-07 10:09:18 +02:00
DL6ER 812743c687 The boolean database should not be set to true at the end of delete_old_queries_in_DB(). The function can in any way not be called when database == false as this is an exit criterion for the database thread.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-07 09:48:41 +02:00
DL6ER 4a9503cbf7 Move checking of database parameter MAXDBDAYS into db_init() to ensure we set database to false.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-07 09:45:12 +02:00
DL6ER 71d9caad43 No need to use heap space for a constant expression.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-06 17:45:05 +02:00
DL6ER 444255b688 Do not assume the database is not available before we actually hit an error.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-06 17:19:41 +02:00
DL6ER 799e3b4230 Reduce three-fold logging of SQL errors to logging them only once. We prefer to handle the logging through the SQLite3 error callback as this ensures it cannot be missed.
Previously:
[2019-07-06 17:00:55.526 32339] SQLite3 message: statement aborts at 36: [CREATE UNIQUE INDEX network_hwaddr_idx ON network(hwaddr)] attempt to write a readonly database (8)
[2019-07-06 17:00:55.526 32339] dbquery(CREATE UNIQUE INDEX network_hwaddr_idx ON network(hwaddr)) - SQL error (8): attempt to write a readonly database
[2019-07-06 17:00:55.526 32339] check_database(8): Disabling database connection due to error
[2019-07-06 17:00:55.526 32339] unify_hwaddr(): "CREATE UNIQUE INDEX network_hwaddr_idx ON network(hwaddr)" failed!

Now:
[2019-07-06 17:00:55.526 32339] SQLite3 message: statement aborts at 36: [CREATE UNIQUE INDEX network_hwaddr_idx ON network(hwaddr)] attempt to write a readonly database (8)
[2019-07-06 17:00:55.526 32339] check_database(8): Disabling database connection due to error
[2019-07-06 17:00:55.526 32339] ERROR: unify_hwaddr() failed!

Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-06 17:10:20 +02:00
DL6ER 8baf8e6022 Improve error handling and logging in database/common.c
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-06 17:03:23 +02:00
DL6ER c944705d52 Table auditlist has been renamed to domain_auditlist.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-06 09:34:50 +02:00
DL6ER 30357a5e5d Audit table name should be 'auditlog'
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-05 17:11:04 +02:00
DL6ER 09b8f91617 Check audit database table instead of file in the API.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-05 16:30:07 +02:00
DL6ER 40a75c25fb Remove extra space.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-05 12:09:50 +02:00
DL6ER 8280f454a8 Change type of get_FTL_db_filesize() from double to long int.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-05 12:05:32 +02:00
DL6ER 104ea1b86a Move database thread into dedicated module.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-04 16:52:17 +02:00
DL6ER a2961d14a4 Merge branch 'development' into new/modularize_headers
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-04 12:21:51 +02:00
DL6ER e365364f72 Move all source files into new subdirectory "src". Put compiled objects into new subdirectory "build".
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-07-02 00:18:56 +02:00