Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Tighten rootful runtime cleanup proof

rcourtmane93ee380847f
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index f51553c328..f5e4cf8c3b 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -7401,9 +7401,11 @@ explicit entrypoint for real rootful Docker and Podman proof on two distinct
disposable Ubuntu/systemd hosts. It never mounts a host daemon socket and runs
the outer containers without a default route. The host image masks Docker and
Podman's distro-managed service, socket, auto-update, transient-cleanup, and
-restart units before first boot; the packet starts only its explicit
-runtime-specific daemon units and requires systemd's strict running state
-before any scenario begins. The packet binds exact clean Go
+restart units plus the distro containerd service before first boot; the packet
+starts only its explicit runtime-specific daemon units, requires systemd's
+exact running state with no failed units before and after each runtime packet,
+and proves the explicit Docker daemon's child containerd exits with that
+daemon. The packet binds exact clean Go
artifacts, every compiled installtests package input, the canonical remote-main
commit, the immutable Ubuntu base-image digest, and governed source hashes,
then records fresh install, legacy migration with authority reduction,
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 09590b5a20..91e7124ad1 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -328,9 +328,12 @@ packet. The explicit
network-isolated Ubuntu/systemd hosts for real rootful Docker and Podman and
never mounts a host daemon socket. The disposable image masks the distro's
Docker and Podman service, socket, auto-update, transient-cleanup, and restart
-units before first boot, so strict systemd readiness cannot be confused with
-expected nested-runtime housekeeping failures; each scenario starts only its
-explicit runtime-specific daemon unit. Its standalone schema-v1 receipt binds the
+units plus the distro containerd service before first boot, so exact systemd
+running state cannot be confused with expected nested-runtime housekeeping
+failures. Each scenario starts only its explicit runtime-specific daemon unit,
+rechecks zero failed units before receipt acceptance, proves the explicit
+Docker daemon's child containerd exits, and removes the complete Podman socket
+boundary during cleanup. Its standalone schema-v1 receipt binds the
exact canonical remote-main commit, immutable Ubuntu base-image digest,
qualification, collector, helper, installer, every compiled installtests
package input, source manifest, canonical root-owned socket, summary inventory,
diff --git a/scripts/installtests/secure_runtime_rootful_qualification_test.go b/scripts/installtests/secure_runtime_rootful_qualification_test.go
index 18eefe31a8..98a9b45134 100644
--- a/scripts/installtests/secure_runtime_rootful_qualification_test.go
+++ b/scripts/installtests/secure_runtime_rootful_qualification_test.go
@@ -108,6 +108,7 @@ func TestSecureRuntimeRootfulQualification(t *testing.T) {
runtimeKind := strings.TrimSpace(os.Getenv("PULSE_ROOTFUL_RUNTIME"))
receiptPath := strings.TrimSpace(os.Getenv("PULSE_ROOTFUL_RECEIPT"))
rootfulQualRequireDisposableHost(t, runtimeKind, receiptPath)
+ rootfulQualAssertSystemContainerdDisabled(t)
collector := secureRuntimeReadArtifact(t, "PULSE_SECURE_RUNTIME_COLLECTOR")
collectorSignature := secureRuntimeReadSignature(t, "PULSE_SECURE_RUNTIME_COLLECTOR_SIGNATURE")
@@ -510,6 +511,38 @@ func rootfulQualStopDaemon(t *testing.T, daemon rootfulQualDaemon) {
t.Helper()
rootlessQualStopUnit(t, daemon.unit)
_ = os.Remove(daemon.socket)
+ if daemon.runtime == "docker" {
+ rootfulQualWaitNoContainerd(t, 20*time.Second)
+ }
+}
+
+func rootfulQualAssertSystemContainerdDisabled(t *testing.T) {
+ t.Helper()
+ unitState := rootlessQualCommand(t, 10*time.Second, "systemctl", "show", "containerd.service", "--property=UnitFileState", "--value")
+ activeState := rootlessQualCommand(t, 10*time.Second, "systemctl", "show", "containerd.service", "--property=ActiveState", "--value")
+ if unitState != "masked" || activeState != "inactive" {
+ t.Fatalf("distro containerd service must be masked and inactive: UnitFileState=%q ActiveState=%q", unitState, activeState)
+ }
+ rootfulQualWaitNoContainerd(t, 5*time.Second)
+}
+
+func rootfulQualWaitNoContainerd(t *testing.T, timeout time.Duration) {
+ t.Helper()
+ deadline := time.Now().Add(timeout)
+ for {
+ output, err := rootlessQualCommandError(3*time.Second, "pgrep", "-x", "containerd")
+ if err != nil {
+ var exitErr *exec.ExitError
+ if errors.As(err, &exitErr) && exitErr.ExitCode() == 1 {
+ return
+ }
+ t.Fatalf("inspect containerd processes: %v\n%s", err, output)
+ }
+ if time.Now().After(deadline) {
+ t.Fatalf("containerd process remained after explicit Docker daemon stop: %s", strings.TrimSpace(output))
+ }
+ time.Sleep(100 * time.Millisecond)
+ }
}
func rootfulQualRuntimeCommand(t *testing.T, daemon rootfulQualDaemon, timeout time.Duration, args ...string) string {
@@ -731,10 +764,19 @@ func rootfulQualRemoveRuntimeState(t *testing.T, daemon rootfulQualDaemon) {
t.Fatalf("remove disposable runtime path %s: %v", path, err)
}
}
+ if daemon.runtime == "podman" {
+ if err := os.Remove(filepath.Dir(daemon.socket)); err != nil && !errors.Is(err, os.ErrNotExist) {
+ t.Fatalf("remove disposable Podman socket directory: %v", err)
+ }
+ }
}
func rootfulQualRuntimeStateClean(daemon rootfulQualDaemon) bool {
- for _, path := range []string{daemon.socket, daemon.dataRoot, daemon.runRoot, daemon.fixture} {
+ paths := []string{daemon.socket, daemon.dataRoot, daemon.runRoot, daemon.fixture}
+ if daemon.runtime == "podman" {
+ paths = append(paths, filepath.Dir(daemon.socket))
+ }
+ for _, path := range paths {
if _, err := os.Lstat(path); !errors.Is(err, os.ErrNotExist) {
return false
}
@@ -1015,6 +1057,7 @@ func TestRootfulQualificationWrapperInvariants(t *testing.T) {
"https://github.com/rcourtman/Pulse.git", "refs/remotes/origin/main", "refs/heads/main",
"PULSE_ROOTFUL_UBUNTU_IMAGE", "PULSE_ROOTFUL_BOUND_PROBE_BINARY",
"rootful_qualification_systemd_readiness",
+ "containerd.service",
"podman-auto-update.service", "podman-auto-update.timer",
"podman-clean-transient.service", "podman-restart.service",
rootfulQualBoundProbe,
@@ -1039,6 +1082,10 @@ func TestRootfulQualificationSystemdReadiness(t *testing.T) {
fakeDocker := filepath.Join(binDir, "docker")
fake := `#!/bin/sh
case "$*" in
+ *"systemctl is-system-running"*)
+ printf '%s\n' "${FAKE_SYSTEMD_MANAGER_STATE:-starting}"
+ [ "${FAKE_SYSTEMD_MANAGER_STATE:-starting}" = running ]
+ ;;
*"systemctl show --property=ActiveState --value multi-user.target"*)
printf '%s\n' "${FAKE_SYSTEMD_TARGET_STATE:-inactive}"
;;
@@ -1056,21 +1103,26 @@ esac
}
tests := []struct {
- name string
- targetState string
- failedUnits string
- wantExit int
- wantOutput string
+ name string
+ managerState string
+ targetState string
+ failedUnits string
+ wantExit int
+ wantOutput string
}{
- {name: "target inactive", targetState: "inactive", wantExit: 1},
- {name: "clean multi-user target", targetState: "active", wantExit: 0},
- {name: "failed unit", targetState: "active", failedUnits: "podman-restart.service loaded failed failed", wantExit: 2, wantOutput: "podman-restart.service"},
+ {name: "manager starting", managerState: "starting", targetState: "active", wantExit: 1},
+ {name: "target inactive", managerState: "running", targetState: "inactive", wantExit: 1},
+ {name: "clean running manager", managerState: "running", targetState: "active", wantExit: 0},
+ {name: "degraded manager", managerState: "degraded", targetState: "active", wantExit: 2, wantOutput: "degraded"},
+ {name: "maintenance manager", managerState: "maintenance", targetState: "active", wantExit: 2, wantOutput: "maintenance"},
+ {name: "failed unit", managerState: "running", targetState: "active", failedUnits: "podman-restart.service loaded failed failed", wantExit: 2, wantOutput: "podman-restart.service"},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
cmd := exec.Command("bash", "-c", `source "$1"; rootful_qualification_systemd_readiness fixture`, "bash", runtimeScript)
cmd.Env = append(os.Environ(),
"PATH="+binDir+":"+os.Getenv("PATH"),
+ "FAKE_SYSTEMD_MANAGER_STATE="+test.managerState,
"FAKE_SYSTEMD_TARGET_STATE="+test.targetState,
"FAKE_SYSTEMD_FAILED_UNITS="+test.failedUnits,
)
diff --git a/scripts/run-secure-runtime-rootful-qualification.sh b/scripts/run-secure-runtime-rootful-qualification.sh
index 2a90e39b5f..70041c1900 100755
--- a/scripts/run-secure-runtime-rootful-qualification.sh
+++ b/scripts/run-secure-runtime-rootful-qualification.sh
@@ -265,6 +265,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
for unit in \
docker.service docker.socket \
+ containerd.service \
podman.service podman.socket \
podman-auto-update.service podman-auto-update.timer \
podman-clean-transient.service podman-restart.service; do \
@@ -332,7 +333,7 @@ run_runtime() {
fi
if (( readiness_status == 2 )); then
capture_qualification_container_diagnostics "${runtime_name}" "${container_id}"
- echo "ERROR: ${runtime_name} disposable systemd container reached multi-user.target with failed units" >&2
+ echo "ERROR: ${runtime_name} disposable systemd container entered a terminal non-running state or has failed units" >&2
return 1
fi
if (( SECONDS >= deadline )); then
@@ -374,11 +375,19 @@ run_runtime() {
-e PULSE_SECURE_RUNTIME_INSTALLER=/opt/pulse/packet/install.sh \
"${container_id}" /opt/pulse/packet/dockeragent.test \
-test.run '^TestSecureRuntimeRootfulQualification$' -test.count=1 -test.v -test.timeout=45m \
- | tee "${OUTPUT_DIR}/${runtime_name}-test.log"; then
+ | tee "${OUTPUT_DIR}/${runtime_name}-test.log"; then
capture_qualification_container_diagnostics "${runtime_name}" "${container_id}"
chmod 0600 "${OUTPUT_DIR}/${runtime_name}-test.log"
return 1
fi
+ readiness_status=0
+ rootful_qualification_systemd_readiness "${container_id}" || readiness_status=$?
+ if (( readiness_status != 0 )); then
+ capture_qualification_container_diagnostics "${runtime_name}" "${container_id}"
+ chmod 0600 "${OUTPUT_DIR}/${runtime_name}-test.log"
+ echo "ERROR: ${runtime_name} systemd readiness changed before receipt acceptance" >&2
+ return 1
+ fi
docker exec "${container_id}" test -f /opt/pulse/result/rootful-receipt.json || {
capture_qualification_container_diagnostics "${runtime_name}" "${container_id}"
echo "ERROR: ${runtime_name} qualification did not retain its receipt" >&2
diff --git a/scripts/secure-runtime-rootful-runtime.sh b/scripts/secure-runtime-rootful-runtime.sh
index f7065841e1..0627b96e95 100644
--- a/scripts/secure-runtime-rootful-runtime.sh
+++ b/scripts/secure-runtime-rootful-runtime.sh
@@ -6,7 +6,28 @@
rootful_qualification_systemd_readiness() {
local container_id="$1"
- local target_state failed_units
+ local manager_state manager_status=0 target_state failed_units
+
+ if manager_state="$(docker exec "${container_id}" systemctl is-system-running 2>/dev/null)"; then
+ manager_status=0
+ else
+ manager_status=$?
+ fi
+ case "${manager_state}" in
+ running)
+ if (( manager_status != 0 )); then
+ printf 'ERROR: systemd reported running with exit status %d\n' "${manager_status}" >&2
+ return 2
+ fi
+ ;;
+ ""|initializing|starting)
+ return 1
+ ;;
+ *)
+ printf 'ERROR: disposable systemd container entered non-running state %q\n' "${manager_state}" >&2
+ return 2
+ ;;
+ esac
target_state="$(docker exec "${container_id}" systemctl show \
--property=ActiveState --value multi-user.target 2>/dev/null)" || return 1