Commit Graph

57 Commits

Author SHA1 Message Date
DL6ER 49094570c4 Enable compile-time flag SQLITE_ENABLE_DBPAGE_VTAB to add support for .recover shell option.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-04-23 17:29:10 +02:00
Petr Čech 74a6b073f1 Merge pull request #1120 from petrcech/patch-1
Fix compilation failure
2021-04-21 22:05:03 +02:00
DL6ER dfb09a35ce Fix database update to version 7 reporting error when there is none. This is not a critical bug as the issue resolves itself on the next start of FTL.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-04-15 10:23:11 +02:00
DL6ER 1115edee18 Always set database pointer to NULL, even when closing failed
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-03-21 10:21:09 +00:00
DL6ER 0795cf6209 Open individual database connections where we need them. Do not use global pointers anywhere. This may mean we have more than one connection open at the sae time. SQLite3 will take care of thread-safety.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-03-20 20:21:09 +00:00
DL6ER 7fdc926f32 Do not close FTL database connection when forking TCP workers
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-03-19 16:03:34 +00:00
DL6ER d53b032342 Avoid leaking memory if dbquery() fails
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-03-19 10:23:52 +00:00
DL6ER eb8de5f0f2 Fix a memory leak when re-opening the databases (when forking or reloading the lists). The memory leak is on the order of a few bytes but scales quickly with the number of clients. It is caused by SQLite3 not being able to clean up behind itself when we're not finalizing and closing everything explicitly.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-03-16 11:37:13 +01:00
DL6ER 7459d8235b Rename memory.c -> syscalls.c
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-12-09 20:21:03 +01:00
DL6ER 471a9e4dee Merge pull request #936 from pi-hole/tweak/disabled_database
Tweaks to disabling the FTL database
2020-11-27 06:22:35 +01:00
DL6ER 26827af625 Merge pull request #926 from pi-hole/new/mesage_dnsmasq_config_errors
Log dnsmasq config errors to pihole-FTL.log
2020-11-26 22:21:40 +01:00
DL6ER 056a70c931 Clarify that disabling the database only disables storing queries in the database. We still use the database for storing messages (such as regex syntax warnings) and alias-clients.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-11-25 19:53:39 +01:00
DL6ER 261d482d58 Store fatal dnsmasq message in message table so it can be used by the Pi-hole dashboard diagnosis system.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-11-17 22:38:32 +01:00
DL6ER 99a07ba57a Rename super-clients ---> alias-clients
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-11-15 19:09:48 +01:00
DL6ER 6f6ae518d2 Merge branch 'development' into new/super-clients
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-11-15 08:47:44 +01:00
DL6ER 23d5440d39 Mark database as being available when creating a new database to avoid FTL skipping adding the tables thinking the database connection isn't ready.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-10-22 21:52:36 +02:00
DL6ER b7fe809467 Reopening the FTL database may lead to rare race-collisions in SQLite3. We avoid them by keeping the database connection open all the time.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-09-27 23:35:44 +02:00
DL6ER 196fca38ff Merge branch 'development' into new/super-clients
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-09-21 23:28:57 +02:00
DL6ER 3bb0fe98be Fix subdirectory include paths. This is only to be explicit, the relative search finds them otherwise as well
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-09-03 20:46:01 +02:00
DL6ER 69c1181085 Change concept of super-clients from MAC-based to index-based. We append a new column to the network table which can be used to assign super-clients to multiple devices. This can both cover automatic grouping (whenever MAC addresses are available) and also situations where this is not possible (when MAC addresses are not available, e.g., due to network layer separation). Real-time signal 3 causes FTL to re-import super-clients from the database without affecting anything else.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-12 19:34:56 +02:00
DL6ER 43eeb53ab6 Import super-clients during start (before all other clients are added)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-11 21:13:36 +02:00
DL6ER aba20cf05c Read superclients from new FTL database table
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-08-11 21:13:36 +02:00
DL6ER 52af8e135b Merge branch 'release/v5.2' into new/mac_clients
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-07-29 12:21:12 +02:00
DL6ER 5f4582e436 Merge pull request #832 from pi-hole/new/cname_inspection_logging
Add logging for CNAME inspection
2020-07-23 06:19:17 +02:00
DL6ER 08b00d2b05 Add additional_info column to queries table. We fill it with the domain that caused blocking the entire CNAME chain.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-07-13 21:18:44 +02:00
DL6ER ee578627a9 Remove privacy level 4. Systems currently running level 4 will automatically pick up the highest available level (which is now 3). Also tidy up enums into a dedicated file.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-07-08 23:48:05 +02:00
DL6ER b5cb27ad3b Skip dbopen() altogether when database is already open
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-06-23 22:11:44 +02:00
DL6ER f18f758808 Merge branch 'development' into new/mac_clients
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-06-05 14:23:36 +02:00
DL6ER 2fcb2bdf53 Only open FTL database for storing a message when there is not already an open connection.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-06-04 14:03:09 +02:00
DL6ER 1438a24a0c Add name and nameUpdated fields to network_addresses table and drop separated network_names table (if exists). The latter is superseded by the extension of the former.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-18 10:08:55 +02:00
DL6ER 9207608879 Create new network_names table. This adds support for multiple hostnames per client (hardware address). Updates pihole-FTL.db version to 7.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-14 18:44:10 +02:00
DL6ER 0e01af2910 Ensure message table is also flushed on receipt of real-time signals.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-11 19:40:43 +02:00
DL6ER 66b592b863 Use BLOBs as datatype for the custom columns to keep this feature as generic as possible. We can always append more columns to the end of the table whenever needed.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-11 01:13:48 +02:00
DL6ER 3e82970c27 Create "message" table and log regex errors in there.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-05-06 21:23:50 +02:00
DL6ER ceb6f049f8 Ensure blocking also works when the long-term database is not used. This was broken before as we returned too early (the SQLite3 engine was not yet fully initialized) when the long-term database was disabled.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-31 17:07:38 +00:00
DL6ER 3a5154bbb8 Merge branch 'release/v5.0' into tweak/sqlite_debugging 2020-03-28 15:13:05 +01:00
DL6ER 2244adedb8 Inform user if queries are being hold in memory for later saving (due to database being locked).
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-24 13:34:16 +01:00
DL6ER 80fbd889f9 Replace sqlite3_errmsg() by sqlite3_errstr() everywhere to ensure we always catch the right error.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-24 10:52:01 +01:00
DL6ER af8ab3ef2f Large-scale overhaul for the long-term database handling.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-24 10:44:27 +01:00
DL6ER 0ac6b5cb69 Implement new SQLite3 subroutine which can interpret IP addresses that may use Classless Inter-Domain Routing (CIDR) notation. This is also known as variable-length subnet masking (VLSM) technique.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2020-03-03 23:35:27 +00: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
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