Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-existing gravity.db issue #1992

Merged
merged 1 commit into from
Jun 6, 2024
Merged

Fix non-existing gravity.db issue #1992

merged 1 commit into from
Jun 6, 2024

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Jun 6, 2024

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:

  • The code change is tested and works locally.
  • I based my code and PRs against the repositories developmental branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

src/database/gravity-db.c Outdated Show resolved Hide resolved
… trying to use the database when it failed to open

Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER merged commit 9491cdf into development-v6 Jun 6, 2024
17 checks passed
@DL6ER DL6ER deleted the fix/no_gravity branch June 6, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants