pi-hole / FTL

The Pi-hole FTL engine
https://pi-hole.net
Other
1.34k stars 187 forks source link

Fix non-existing gravity.db issue #1992

Closed DL6ER closed 3 weeks ago

DL6ER commented 3 weeks ago

What does this implement/fix?

Add checking of return status of sqlite3_open_v2() to ensure we are not trying to use the database when it failed to open (e.g., when it does not exist).

Errors on development-v6:

2024-06-06 06:48:34.042 CEST [2901888/T2901896] ERROR: SQLite3: cannot open file at line 44775 of [96c92aba00] (14)
2024-06-06 06:48:34.042 CEST [2901888/T2901896] ERROR: SQLite3: os_unix.c:44775: (0) open(/etc/pihole/gravity.db) -  (14)
2024-06-06 06:48:34.042 CEST [2901888/T2901896] ERROR: SQLite3: API call with unopened database connection pointer (21)
2024-06-06 06:48:34.042 CEST [2901888/T2901896] ERROR: SQLite3: misuse at line 142653 of [96c92aba00] (21)
2024-06-06 06:48:34.042 CEST [2901888/T2901896] WARNING: gravity_updated(): SELECT value FROM info WHERE property = 'updated'; - SQL error prepare: bad parameter or other API misuse

Errors on this branch:

2024-06-06 06:47:53.012 CEST [2901383/T2901392] ERROR: Cannot read gravity database at /etc/pihole/gravity.db - file does not exist or is not readable

Note that FTL works flawlessly (in terms of DNS resolution, but obviously without any blocking when gravity.db is missing) on either branch. This is merely cosmetic.


Related issue or feature (if applicable): N/A

Pull request in docs with documentation (if applicable): N/A


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

Checklist: