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

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

Merged
merged 7 commits into from
Nov 22, 2023

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Nov 6, 2023

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

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

Copy link

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

Copy link

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
src/config/config.c Outdated Show resolved Hide resolved
Co-authored-by: yubiuser <ckoenig@posteo.de>
Signed-off-by: DL6ER <DL6ER@users.noreply.github.com>
src/config/config.c Outdated Show resolved Hide resolved
Copy link
Member

@yubiuser yubiuser left a comment

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>
src/config/toml_reader.c Outdated Show resolved Hide resolved
Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER requested a review from yubiuser November 21, 2023 21:36
@yubiuser
Copy link
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

Copy link

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

Copy link

Conflicts have been resolved.

@DL6ER DL6ER merged commit 70a34e2 into development-v6 Nov 22, 2023
17 checks passed
@DL6ER DL6ER deleted the fix/read_rotated_toml_on_error branch November 22, 2023 22:16
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.

None yet

3 participants