-
-
Notifications
You must be signed in to change notification settings - Fork 202
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 file ownership after pihole-FTL --config as root #2145
Conversation
…fig as root Signed-off-by: catch-error <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR! I have only very litte suggestions. The const
are really just to try to prevent possible new mistakes in the future. The larger suggestion is to document the logic in the code. Any compiler will wipe out the const bool
during optimization so this should be equivalent in actual machine code to your initial suggestion but IMO is much more readable for humans.
Signed-off-by: catch-error <[email protected]>
Thx for your suggestions @DL6ER. They're done now. |
We're currently seeing issues with the CI, seems ARM runner are currently unavailable. I'll approve and merge once this is resolved |
Strange... I've now run builds on Raspi OS 12 (aarch64), Debian 12 (x86_64), Ubuntu 24.04 (aarch64 & x86_64) and Fedora 40 (aarch64 & x86_64). All builds go through w/o issues. toml_helper.c includes sys/file.h, which in turn includes fcntl.h. I can add an explicit include to fcntl.h as well, looks like some environments need this. |
The CI builds against libmusl on Alpine Linux - from what I can see, all your test systems use GNU libc. Alpine Linux ships with the rather new gcc v14.2.0. |
Signed-off-by: catch-error <[email protected]>
Ok, I see. I need to enhance my build environments. It now also compiles on Alpine Linux. |
What does this PR aim to accomplish?:
When calling pihole-FTL --config key value as root, the resulting pihole.toml and dnsmasq.conf files in /etc/pihole are owned by root:root. It should be pihole:pihole.
How does this PR accomplish the above?:
pihole.toml: Root cause is that when openFTLtoml() is called with mode "w", it'll not open pihole.toml, but pihole.toml.tmp instead. closeFTLtoml(), however, always calls chown_pihole() on pihole.toml. As in the next step pihole.toml.tmp gets renamed to pihole.toml, its root:root ownership persists.
This patch evaluates the open mode in closeFTLtoml(), changing the ownership of pihole.toml.tmp if the mode isn't O_RDONLY.
dnsmasq.conf: Add a call to chown_pihole() for the temporary file, if called as root.
Link documentation PRs if any are needed to support this PR:
N/A
By submitting this pull request, I confirm the following:
git rebase
)