Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion deploy/pihole-maintenance-web.sudoers
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ pihole-suite ALL=(root) NOPASSWD: /usr/bin/systemctl start --no-block pihole-mai
pihole-suite ALL=(root) NOPASSWD: /usr/bin/systemctl start --no-block pihole-maintenance-backup.service
pihole-suite ALL=(root) NOPASSWD: /usr/bin/systemctl start --no-block pihole-maintenance-update.service
pihole-suite ALL=(root) NOPASSWD: /usr/local/libexec/pihole-maintenance-backups ^delete [0-9]{8}T[0-9]{6}Z-[0-9]{8}T[0-9]{12}Z-[a-f0-9]{32}$
pihole-suite ALL=(root) NOPASSWD: /usr/local/libexec/pihole-suite-upstreams ""
2 changes: 1 addition & 1 deletion start_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def to_iso(epoch: str) -> str | None:


def _read_pihole_v6_upstreams() -> list[str] | None:
result = _run(["/usr/bin/sudo", "-n", "/usr/local/libexec/pihole-suite-upstreams"], timeout=2.0)
result = _run(["/usr/local/libexec/pihole-suite-upstreams"], timeout=2.0)
if not result.get("ok") or result.get("returncode") != 0 or result.get("stderr"):
return None
try:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_install_maintenance_web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ assert_mode "$SUDOERS" 440
for action in check backup update; do
grep -Fqx "pihole-suite ALL=(root) NOPASSWD: /usr/bin/systemctl start --no-block pihole-maintenance-${action}.service" "$SUDOERS"
done
test "$(grep -Ec '^pihole-suite ALL=' "$SUDOERS")" = 5
grep -Fqx 'pihole-suite ALL=(root) NOPASSWD: /usr/local/libexec/pihole-suite-upstreams ""' "$SUDOERS"
test "$(grep -Ec '^pihole-suite ALL=' "$SUDOERS")" = 4
! grep -Fq '/usr/local/libexec/pihole-suite-upstreams' "$SUDOERS"
! grep -Eq '[*]|ALL[[:space:]]*=.*(sh|bash)' "$SUDOERS"

CADDY_MAIN="$DESTDIR/etc/caddy/Caddyfile"
Expand Down
6 changes: 6 additions & 0 deletions tests/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ def test_upstreams_helper_rejects_warning_and_invalid_json(monkeypatch):
monkeypatch.setattr(start_suite, "_run", lambda *a, **kw: {"ok": True, "returncode": 0, "stdout": '["127.0.0.1#5335"]', "stderr": ""})
assert start_suite._read_pihole_v6_upstreams() == ["127.0.0.1#5335"]

def test_upstreams_helper_runs_without_privilege_escalation(monkeypatch):
calls = []
monkeypatch.setattr(start_suite, "_run", lambda cmd, **kwargs: calls.append(cmd) or {"ok": True, "returncode": 0, "stdout": '["127.0.0.1#5335"]', "stderr": ""})
assert start_suite._read_pihole_v6_upstreams() == ["127.0.0.1#5335"]
assert calls == [["/usr/local/libexec/pihole-suite-upstreams"]]

def test_root_serves_maintenance():
response = client.get("/", follow_redirects=False)
assert response.status_code == 200
Expand Down
Loading