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

Allow pihole to access subdirs in /etc/pihole #5427

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

yubiuser
Copy link
Member

What does this PR aim to accomplish?:

Before FTL starts we execute the pre-start script, which ensures that permissions are set correctly to various files and dirs.

# Ensure that permissions are set so that pihole-FTL can edit all necessary files
chown -R pihole:pihole /etc/pihole /var/log/pihole
chmod -R 0640 /var/log/pihole
chmod -R 0660 /etc/pihole
# allow all users to enter the directories
chmod 0755 /etc/pihole /var/log/pihole

However, we forgot to set the execution bit on the subdirs in /etc/pihole so FTL (running as pihole user) was not able to access the dirs , despite being the owner of the dirs. This resulted in errors on each FTL restart like

2023-10-13 08:58:14.547 [180M] WARNING: copy_file(): Failed to open "/etc/pihole/config_backups/pihole.toml.1" for writing: Permission denied
2023-10-13 08:58:14.547 [180M] WARNING: Rotation /etc/pihole/pihole.toml -(COPY)> /etc/pihole/config_backups/pihole.toml.1 failed
2023-10-13 08:58:14.547 [180M] INFO: Writing config file
2023-10-13 08:58:14.548 [180M] WARNING: copy_file(): Failed to open "/etc/pihole/config_backups/dnsmasq.conf.1" for writing: Permission denied
2023-10-13 08:58:14.548 [180M] WARNING: Rotation /etc/pihole/dnsmasq.conf -(COPY)> /etc/pihole/config_backups/dnsmasq.conf.1 failed
2023-10-13 08:58:14.548 [180M] WARNING: copy_file(): Failed to open "/etc/pihole/config_backups/custom.list.1" for writing: Permission denied
2023-10-13 08:58:14.548 [180M] WARNING: Rotation /etc/pihole/custom.list -(COPY)> /etc/pihole/config_backups/custom.list.1 failed

How does this PR accomplish the above?:

Set the execution bit on subdirs in /etc/pihole.


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 and I have tested my changes.
  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)
  6. I have checked that another pull request for this purpose does not exist.
  7. I have considered, and confirmed that this submission will be valuable to others.
  8. I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  9. I give this submission freely, and claim no ownership to its content.

  • I have read the above and my PR is ready for review. Check this box to confirm

@yubiuser yubiuser requested a review from a team October 13, 2023 18:04
@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/user-pihole-permissions-on-pihole-folders-are-not-writable/65443/12

@yubiuser yubiuser added PR: Approval Required Open Pull Request, needs approval Pi-hole v6.0 labels Oct 13, 2023
Signed-off-by: Christian König <ckoenig@posteo.de>
Copy link
Member

@DL6ER DL6ER left a comment

Choose a reason for hiding this comment

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

We will finally get all the permissions right

# allow all users to enter the directories
chmod 0755 /etc/pihole /var/log/pihole

# allow pihole to access subdirs in /etc/pihole (sets execution bit on dirs)
# credits https://stackoverflow.com/a/11512211
find /etc/pihole -type d -exec chmod 0755 {} \;
Copy link
Member

Choose a reason for hiding this comment

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

That's some very interesting solution. I'd probably have done it on an individual basis but I do see how this will prevent us from forgetting to address this in the future 👍

@yubiuser yubiuser merged commit 6ae713e into development-v6 Oct 13, 2023
15 checks passed
@yubiuser yubiuser deleted the fix/subdir_permissions branch October 13, 2023 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pi-hole v6.0 PR: Approval Required Open Pull Request, needs approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants