pi-hole/advanced/Templates
Adam Warner a360b14b61
fix: run the permission fix-up in prestart as the pihole user
pihole-FTL-prestart.sh runs as root (ExecStartPre=+) and, right after
chown-ing /etc/pihole and /var/log/pihole to the pihole user, walks them
with `find ... -exec chmod`. find only builds a list of paths and chmod
acts on them afterwards, so the pihole user can swap a directory or file
for a symlink in between; root's chmod then follows it and changes the
permissions of a file pihole has no business touching (e.g. 0755 on
/etc/shadow makes it world-readable).

Reproduced against the stock script: with a pihole-owned loop flipping a
directory name between "real directory" and "symlink to a root-only
file", the file went from 0600 to 0755 within a handful of restarts.

Run the three find calls as the pihole user instead. It owns everything
below those directories, and a symlink pointing anywhere else only yields
a permission error. Failure stays non-fatal so it can never stop FTL from
starting.

Add a deterministic test: with the script's chown stubbed out, a
root-owned probe stays untouched only if the fix-up does not run as root.

This is independent of the other changes in this series and applies to
the same pre-existing code on master/development, so it can be
cherry-picked on its own.

Reported-by: Keith Linneman (LinnemanLabs)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
2026-10-15 19:48:02 +01:00
..
gravity.db.sql Rename views, upgrade gravity database and bump gravity databae version 2025-08-15 19:39:21 +02:00
gravity_copy.sql Remove remaining traces of audit log 2024-11-16 09:45:53 +01:00
logrotate logrotate: merge FTL and webserver as they share all options, this 2026-08-19 22:16:13 +02:00
pihole-FTL-poststop.sh security: hardcode PID file path in service hooks 2026-04-19 16:42:58 +01:00
pihole-FTL-prestart.sh fix: run the permission fix-up in prestart as the pihole user 2026-10-15 19:48:02 +01:00
pihole-FTL.openrc Fix libcap capabilities not being granted on OpenRC distros 2025-11-02 07:29:20 +11:00
pihole-FTL.service security: hardcode PID file path in service hooks 2026-04-19 16:42:58 +01:00
pihole-FTL.systemd systemd service - don't use deprecated PermissionsStartOnly 2025-11-08 15:35:10 +10:00
pihole.cron fix: don't let root write the version file into pihole-owned /etc/pihole 2026-10-15 19:47:57 +01:00