mirror of
https://github.com/pi-hole/pi-hole.git
synced 2026-11-23 16:48:52 +00:00
updatecheck.sh writes the versions file into /etc/pihole, which is owned by the unprivileged pihole user. When it ran as root (the installer, `pihole -up`, `pihole checkout`, `sudo pihole updatechecker`, the Docker start-up check, ...) the pihole user could watch the directory, swap the script's temporary file for a symlink and have root chmod/chown/append to whatever it pointed at. Reproduced: a root-only file ended up owned by pihole. - When started as root, hand over to the pihole user (`su`) and exit with its result. This covers every caller, including future ones, and the pihole user can only damage what it already owns. The "reboot" argument is forwarded. - Drop the chown of the temporary file; it is no longer needed and was the dangerous part. - Use `mv -fT` so that a symlink to a directory at the target path is replaced rather than having the temporary file moved into the directory. Tests (fresh install): started as root the script must do its work as the pihole user and write a pihole-owned 0644 versions file; a symlink (to a file or to a directory) at the target path must be replaced rather than followed. Note: running as the pihole user needs git to trust the root-owned Core and Web repositories (safe.directory). The installer sets that up (see the following commit); other installers of this script, such as the Docker image, need the equivalent. Reported-by: Keith Linneman (LinnemanLabs) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Adam Warner <me@adamwarner.co.uk> |
||
|---|---|---|
| .. | ||
| _alpine_3_21.Dockerfile | ||
| _alpine_3_22.Dockerfile | ||
| _alpine_3_23.Dockerfile | ||
| _alpine_3_24.Dockerfile | ||
| _centos_9.Dockerfile | ||
| _centos_10.Dockerfile | ||
| _debian_12.Dockerfile | ||
| _debian_13.Dockerfile | ||
| _fedora_40.Dockerfile | ||
| _fedora_41.Dockerfile | ||
| _fedora_42.Dockerfile | ||
| _fedora_43.Dockerfile | ||
| _fedora_44.Dockerfile | ||
| _ubuntu_20.Dockerfile | ||
| _ubuntu_22.Dockerfile | ||
| _ubuntu_24.Dockerfile | ||
| _ubuntu_26.Dockerfile | ||
| bats_helper.bash | ||
| README.md | ||
| run.sh | ||
| test_automated_install.bats | ||
| test_fresh_install.bats | ||
| test_gravity.bats | ||
| test_installer_ftl.bats | ||
| test_network.bats | ||
| test_selinux.bats | ||
| test_symlink_safety.bats | ||
| test_utils.bats | ||
Recommended way to run tests
The test suite is implemented with BATS and runs inside distro-specific Docker containers.
Requirements
- Docker (with buildx support)
- Bash shell
Run tests
From the repository root, run:
bash test/run.sh --distro debian_12
test/run.sh will:
- Build the distro test image from
test/_<distro>.Dockerfile - Run the mock/function BATS suite in a fresh container
- Run the fresh-install BATS suite in a separate fresh container
Available distros
If you are unsure which distro names are valid, run:
bash test/run.sh --help
The help output includes the current list of supported distros.
Optional: override BATS library versions
test/run.sh accepts optional environment variable overrides when building test images:
BATS_CORE_VERBATS_SUPPORT_VERBATS_ASSERT_VERBATS_MOCK_VERBATS_FILE_VER
Example:
BATS_CORE_VER=v1.14.0 DISTRO=debian_12 bash test/run.sh