Repository navigation
Depend on polkit so the packaged watchdog can heal Tor - #191
Merged
Merged
Conversation
Every native package creates the ttp-watchdog account, so the watchdog runs as that account and restarts a stopped or crashed ttp-tor.service through polkit (50-ttp-watchdog.rules). Only polkitd reads that rule, and no package depended on it. Measured on Debian 13 (systemd as PID 1, the packaged account and rule, a stand-in ttp-tor.service): without polkitd `systemctl restart ttp-tor.service` as ttp-watchdog is "Access denied"; with polkitd 126 it succeeds, while another unit and another account are still refused. In the watchdog a refused restart is a failed heal, which engages the emergency killswitch: no leak, but a Tor restart left the host without network. The .deb now depends on polkitd, the .rpm and the PKGBUILD on polkit. test_packaging_dependencies.py requires it of all three (it failed before). The package smoke test also requires the account, polkitd and a readable rule; run on the released 0.5.1 .deb it fails, and the new .deb passes on Debian 13 and Ubuntu 24.04. The VM jobs install TTP with pip, where the watchdog runs as root, and the chaos sweep counts a killswitch as contained, so none of them could see this. scripts/vm/lifecycle/heal.sh installs the .deb in a Debian guest, stops ttp-tor and requires a heal without a killswitch, then masks polkit and requires the same fault to end in the killswitch, so the check can fail. It runs as a new job in lifecycle.yml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: onyks-os <129986281+onyks-os@users.noreply.github.com>
The first run of heal.sh waited for "Restarted Tor service successfully" and timed out. That line is logged at INFO, and the watchdog running as ttp-watchdog cannot open root's log file, so only WARNING and above reach its journal: the run shows "Initiating auto-healing for failed component 'tor'" and no error after it. The heal is now judged by: the watchdog's healing line, a new "Started ttp-tor.service" from systemd, ttp-tor active, and, past the next 15 s check, no killswitch and neither "Failed to restart Tor service" nor "Local integrity failure in tor". The control looks for the refused restart that integrity.py logs on the supervisor's path, not the FSM's message, which that path never emits. The journals of ttp-tor and polkit are kept with the logs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: onyks-os <129986281+onyks-os@users.noreply.github.com>
onyks-os
added a commit
that referenced
this pull request
Nov 30, 2026
* Log the watchdog's INFO lines to the journal The native packages run the watchdog as ttp-watchdog, which cannot open root's /run/ttp/ttp.log (0600). setup_logging() returned early in that case, before any console handler, so the ttp logger had no handler at all: Python's last-resort handler printed WARNING and above, and INFO lines appeared nowhere, a healed Tor among them. Found by the first run of scripts/vm/lifecycle/heal.sh (#191), which waited for the heal's INFO line in the journal and never saw it. A file that cannot be opened now skips only the file handler. When systemd has connected stderr to the journal (JOURNAL_STREAM names stderr's device and inode, as the variable is inherited by children), and no console handler is configured, INFO and above go to stderr, each line prefixed with its syslog priority (<6>, <4>, ...), so journalctl records the level and -p filters on it. A root watchdog keeps its file and gains the journal; --quiet keeps the journal quiet; a CLI run from a terminal is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: onyks-os <129986281+onyks-os@users.noreply.github.com> * Require the heal's INFO line in the packaged watchdog's journal With the journal handler, the watchdog running as ttp-watchdog logs "Watchdog: Restarted Tor service successfully." at INFO. heal.sh now requires that line, read with `journalctl -p info..info` so the priority journald recorded is checked too. Before this branch the confined watchdog logged nothing below WARNING, and this check would have failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: onyks-os <129986281+onyks-os@users.noreply.github.com> --------- Signed-off-by: onyks-os <129986281+onyks-os@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every native package (
.deb,.rpm, PKGBUILD) creates thettp-watchdogaccount, so the watchdog runs as that account. When Tor stops or crashes, it restartsttp-tor.servicethrough polkit, using50-ttp-watchdog.rules. That rule is read by polkitd alone, and no package depended on polkit.Measured on Debian 13, with systemd as PID 1, the packaged account and rule, and a stand-in
ttp-tor.service:systemctl restart ttp-tor.serviceasttp-watchdogAccess deniedIn the watchdog, a refused restart is a failed heal (
ttp/watchdog/integrity.py:286), and a failed heal goes toheal_failand then the emergency killswitch. Nothing leaks, but a Tor restart leaves the host with no network until the user steps in. This affects hosts without polkit, such as servers and minimal installs.Fix
.debnow depends onpolkitd, and the.rpmand PKGBUILD onpolkit.tests/test_packaging_dependencies.pyrequires this of all three. It failed before the change.packaging/smoke_test.shalso requires the account, polkitd and a readable rule:.debit fails;.debpasses on Debian 13 and Ubuntu 24.04 (run locally).New VM scenario
The other VM jobs install TTP with pip. With no account, the watchdog runs as root, and the chaos sweep counts a killswitch as contained, so none of them could see this.
scripts/vm/lifecycle/heal.sh(new job Watchdog heals Tor as packaged) runs three steps:.debwith apt in a Debian 13 guest, and require polkitd and a watchdog unit running withUser=ttp-watchdog.systemctl stop ttp-tor, then require the watchdog to log the restart,ttp-torto be active again, and no killswitch.This PR's run of that job is its first end-to-end run.
🤖 Generated with Claude Code