fix(system_baseline): run the apt upgrade with TMPDIR outside /tmp and /var/tmp
Build / build (pull_request) Successful in 31s
Lint / lint (pull_request) Canceled after 1m40s
Molecule / molecule (pull_request) Canceled after 1m13s

An openssh-server upgrade restarts ssh.service. With PrivateTmp=yes systemd
then deletes that unit's /tmp and /var/tmp, which removes the files apt
staged there while the upgrade is still running, so dpkg fails and leaves
packages unpacked but not configured.

The update flow now creates system_baseline_apt_tmpdir (root, mode 0700),
runs the upgrade and the autoremove with TMPDIR set to it, and opens a new
connection afterwards. The input is validated in the main flow and in the
update entry point: absolute, no "..", not under /tmp or /var/tmp.

Closes #374

Assisted-by: Claude Code:claude-sonnet-5-5
This commit is contained in:
Dragonish committed 2026-11-25 19:21:01 +00:00
1 parent 008c5ab8a4
commit 1bbf3368ee
11 files changed
+151 -1

No files matched your search

@@ -0,0 +1,12 @@
---
bugfixes:
- >-
system_baseline - the apt upgrade no longer loses its staged packages when it upgrades ``openssh-server`` on a host whose
``ssh.service`` has ``PrivateTmp=yes``. The restart of that unit deleted ``/tmp`` and ``/var/tmp`` in the middle of the upgrade, so
dpkg failed with "cannot access archive" and left packages unpacked but not configured. The upgrade and the autoremove now run with
``TMPDIR`` set to ``system_baseline_apt_tmpdir``, and the role opens a new connection afterwards.
minor_changes:
- >-
system_baseline - add ``system_baseline_apt_tmpdir`` (default ``/var/cache/system-baseline-apt-tmp``), the directory the apt upgrade and
autoremove use as ``TMPDIR``. The role creates it (root, mode ``0700``) when it runs the ``update`` flow, including the ``update`` entry
point, and refuses a value under ``/tmp`` or ``/var/tmp``, a relative path or a ``..``.