Skip to content

Try to restore broken pihole.toml from rotated files#1738

Merged
DL6ER merged 7 commits into
development-v6from
fix/read_rotated_toml_on_error
Nov 22, 2023
Merged

Try to restore broken pihole.toml from rotated files#1738
DL6ER merged 7 commits into
development-v6from
fix/read_rotated_toml_on_error

Conversation

@DL6ER

@DL6ER DL6ER commented Nov 6, 2023

Copy link
Copy Markdown
Member

What does this implement/fix?

If reading pihole.toml fails during startup of FTL, we should restore from the last known-to-be-good rotated config file in /etc/pihole/config_backups and only if they don't exist (migrating from v5.x -> v6.0), we start importing the legacy files.

Note that this problem is actually not an issue when the config file is modified and becomes invalid while FTL is running. In this case, FTL simply discards the file and overwrites it with its current configuration (which is in this case the last-known-to-be-good one).

This fixes an observation by @yubiuser where incorrectly escaped Umlauts triggered a "partial config reset". This was actually not a partial reset but FTL trying to restore from your previous v5.x files. This is fixed in this PR be instead using /etc/pihole/config_backup/pihole.toml.X (X = 1,2,3) to recreate /etc/pihole/pihole.toml.


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.

…ll existing setupVars.conf, etc. files. However, it arguably makes more sense to instead restore from the last known-to-be-good rotated config file in /etc/pihole/config_backups

Signed-off-by: DL6ER <dl6er@dl6er.de>
@pralor-bot

Copy link
Copy Markdown

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/web-server-issues/66155/8

@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions

Copy link
Copy Markdown

Conflicts have been resolved.

@DL6ER DL6ER force-pushed the fix/read_rotated_toml_on_error branch from 7eca379 to f45fe2f Compare November 18, 2023 14:07
@DL6ER DL6ER force-pushed the fix/read_rotated_toml_on_error branch from f45fe2f to 1a517c7 Compare November 18, 2023 15:13
Comment thread src/config/config.c Outdated
Co-authored-by: yubiuser <ckoenig@posteo.de>
Signed-off-by: DL6ER <DL6ER@users.noreply.github.com>
Comment thread src/config/config.c Outdated

@yubiuser yubiuser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think even more can go

Screenshot at 2023-11-19 22-54-57

@DL6ER DL6ER force-pushed the fix/read_rotated_toml_on_error branch from 72f9a2c to 98f7ff8 Compare November 19, 2023 21:58
DL6ER added a commit that referenced this pull request Nov 20, 2023
Signed-off-by: DL6ER <dl6er@dl6er.de>
Comment thread src/config/toml_reader.c Outdated
Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER requested a review from yubiuser November 21, 2023 21:36
@yubiuser

Copy link
Copy Markdown
Member

Looks fine.

2023-11-22 13:54:33.490 [27128M] INFO: Config file /etc/pihole/pihole.toml not available: No such file or directory
2023-11-22 13:54:33.490 [27128M] INFO: Config backup file /etc/pihole/config_backups/pihole.toml.1 not available: No such file or directory
2023-11-22 13:54:33.490 [27128M] INFO: Using config backup /etc/pihole/config_backups/pihole.toml.2

@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions

Copy link
Copy Markdown

Conflicts have been resolved.

@DL6ER DL6ER merged commit 70a34e2 into development-v6 Nov 22, 2023
@DL6ER DL6ER deleted the fix/read_rotated_toml_on_error branch November 22, 2023 22:16
@PromoFaux PromoFaux mentioned this pull request Feb 18, 2025
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.

3 participants