From 46f9bda252f5cbdf6c322a2b8399e8c67be2f401 Mon Sep 17 00:00:00 2001 From: Kevin Stenzel Date: Mon, 28 Sep 2026 15:56:45 +0200 Subject: [PATCH 1/5] fix(debian): upgrades keep a service the admin disabled Up to 7.3.5 every configure ran `systemctl enable` and started the service, so an admin's `systemctl disable --now` was undone by the next upgrade. The maintainer scripts now follow Debian's rules the way the dh_installsystemd snippets do, still by hand because the unit stays in /lib/systemd/system: * postinst: deb-systemd-helper unmask, then enable when was-enabled, update-state otherwise (links are made without a running systemd too). With systemd running: an enabled unit is restarted on upgrade (started on a new installation) with deb-systemd-invoke; a disabled or masked one only gets try-restart (a running one loads the new code, a stopped one stays stopped). The instance update runs only when the service runs after the configure, otherwise apt shows one line saying so. * preinst (new): one-time transition. 7.3.5 and older never recorded deb-systemd-helper state, and without it was-enabled says "enabled" even for a disabled unit. On an upgrade without recorded state the current state is recorded (enabled -> enable, otherwise update-state; the latter only while systemd runs: without it the old postinst never enabled the unit). A reinstall from config-files is not an upgrade. * prerm remove: deb-systemd-invoke stop only (no disable). * postrm remove: deb-systemd-helper mask; purge: purge + unmask. Measured in a systemd container (ubuntu:24.04, init-system-helpers 1.66ubuntu1): deb-systemd-invoke restart of a masked running unit fails and of a disabled stopped one prints "not starting it", try-restart is silent in both, so only enabled units get restart/start. debian/changelog: 7.3.6 (lmn73). --- debian/changelog | 33 +++++++++++++++++++++++++++++++ debian/postinst | 48 ++++++++++++++++++++++++++++++++++------------ debian/postrm | 10 ++++++++++ debian/preinst | 27 ++++++++++++++++++++++++++ debian/prerm | 10 ++++++---- debian/rules | 3 ++- docs/install.md | 11 +++++++---- docs/operations.md | 44 +++++++++++++++++++++++++++++++++++++----- 8 files changed, 160 insertions(+), 26 deletions(-) create mode 100644 debian/preinst diff --git a/debian/changelog b/debian/changelog index 6e97941..94acd78 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,36 @@ +linuxmuster-radius (7.3.6) lmn73; urgency=medium + + * Upgrades respect a service the admin switched off. Up to 7.3.5 every + install, upgrade and dpkg-reconfigure enabled and started + linuxmuster-radius.service again, and updated the RADIUS instances + through it (lmnradius update-all). + The package now follows Debian's rules (deb-systemd-helper and + deb-systemd-invoke, as packages built with dh_installsystemd do): a new + installation enables and starts the service; after that, upgrades keep + the admin's decision. Enabled: the service is restarted with the new + code, and started if it was stopped. Disabled ("systemctl disable + --now linuxmuster-radius"): it stays disabled and stopped, the + instances are not updated, and apt shows one line saying so; run + "lmnradius update-all" after starting the service. Disabled but still + running: restarted with the new code, not enabled. Masked: left alone. + docs/operations.md explains how to keep the service off. + * The first upgrade to 7.3.6 takes over the state the service is in at + that moment (the new preinst records it once), because 7.3.5 and older + kept no record of it: a service that is disabled then stays disabled. + * Removing the package now only stops the service; it is no longer + disabled. The decision is kept while the package is removed and applies + again when it is reinstalled; purge forgets it. Reinstalling after + removing 7.3.5 or older enables and starts the service like a new + installation. + * Installed without a running systemd (an image build, a chroot), the + service is now enabled and starts with the next boot; before, it was not + enabled at all. Where /usr/sbin/policy-rc.d forbids starting services + (build containers), the package no longer starts or restarts it. + * A downgrade to 7.3.5 or older brings the old behaviour back: that + version enables and starts the service again on its install. + + -- Kevin Stenzel Mon, 28 Sep 2026 15:29:04 +0200 + linuxmuster-radius (7.3.5) lmn73; urgency=medium * The API's OpenAPI document (/openapi.json, the interactive docs under diff --git a/debian/postinst b/debian/postinst index 20042ef..6cb6d95 100644 --- a/debian/postinst +++ b/debian/postinst @@ -112,21 +112,45 @@ fi # blanket 0755), so anything intentionally restrictive stays as restrictive as it was. chmod -R go-w /opt/linuxmuster-radius +# The service by Debian's rules, as dh_installsystemd's snippets do it, by hand because the +# unit stays in /lib/systemd/system (moving it to /usr/lib within one package risks losing it +# under usrmerge). deb-systemd-helper keeps the admin's decision: a new installation enables +# the service, afterwards it stays as the admin left it, so `systemctl disable` survives +# upgrades (up to 7.3.5 every configure enabled it again). The preinst recorded the state of a +# server coming from 7.3.5 or older. Without a running systemd (image build, chroot) only the +# links are made and the service starts with the next boot. +UNIT=linuxmuster-radius.service +deb-systemd-helper unmask "$UNIT" >/dev/null || true +if deb-systemd-helper --quiet was-enabled "$UNIT"; then + deb-systemd-helper enable "$UNIT" >/dev/null || true +else + deb-systemd-helper update-state "$UNIT" >/dev/null || true +fi + if [ -d /run/systemd/system ]; then systemctl daemon-reload || true - systemctl enable linuxmuster-radius.service || true - # Load new code on a genuine upgrade (try-restart no-ops if the service is not - # running), then start unconditionally so it is up in ALL cases -- fresh install - # AND reinstall over a removed/config-files state, where try-restart alone would - # leave it stopped. `start` is a no-op if it is already running. - if [ -n "${2:-}" ]; then - systemctl try-restart linuxmuster-radius.service || true + # Enabled: restart on an upgrade (loads the new code, starts a stopped service), start on + # a new installation. Disabled or masked: only try-restart, so a service that still runs + # gets the new code and a stopped one stays stopped (restart would do the same for a + # disabled unit but print "not starting it", and it fails on a masked unit that runs). + # deb-systemd-invoke honours policy-rc.d. + if [ "$(systemctl is-enabled "$UNIT" 2>/dev/null)" = enabled ]; then + if [ -n "${2:-}" ]; then + deb-systemd-invoke restart "$UNIT" || true + else + deb-systemd-invoke start "$UNIT" || true + fi + else + deb-systemd-invoke try-restart "$UNIT" || true fi - systemctl start linuxmuster-radius.service || true - # On upgrade, lift all running instances onto this package's pinned default - # image (best-effort; each instance updates with its own health-check - # auto-rollback). Wait briefly for the restarted API; never fail the install. - if [ -n "${2:-}" ]; then + # On upgrade, lift all instances onto this package's pinned default image (best-effort; + # each instance updates with its own health-check auto-rollback), but only through a + # service that runs after this configure; a service the admin keeps off is not started + # for it. Wait briefly for the restarted API; never fail the install. + if [ -n "${2:-}" ] && ! systemctl is-active --quiet "$UNIT"; then + echo "linuxmuster-radius: the service is $(systemctl is-enabled "$UNIT" 2>/dev/null)" \ + "and not running, instances not updated; run 'lmnradius update-all' after starting it" + elif [ -n "${2:-}" ]; then LMN=/opt/linuxmuster-radius/venv/bin/lmnradius i=0 while [ "$i" -lt 30 ]; do diff --git a/debian/postrm b/debian/postrm index 7f703c5..624a714 100644 --- a/debian/postrm +++ b/debian/postrm @@ -5,8 +5,18 @@ set -e if [ -d /run/systemd/system ]; then systemctl daemon-reload || true fi +# The admin's enable/disable decision survives a remove (the unit stays masked until the +# postinst of a reinstall unmasks it) and is forgotten on purge; Debian's rule, as +# dh_installsystemd does it. +if [ "$1" = remove ] && [ -x /usr/bin/deb-systemd-helper ]; then + deb-systemd-helper mask linuxmuster-radius.service >/dev/null || true +fi # Deliberately do NOT delete config/state + venv on remove (only on purge). if [ "$1" = "purge" ]; then + if [ -x /usr/bin/deb-systemd-helper ]; then + deb-systemd-helper purge linuxmuster-radius.service >/dev/null || true + deb-systemd-helper unmask linuxmuster-radius.service >/dev/null || true + fi rm -rf /opt/linuxmuster-radius rm -rf /etc/linuxmuster-radius /var/lib/linuxmuster-radius fi diff --git a/debian/preinst b/debian/preinst new file mode 100644 index 0000000..3d8d432 --- /dev/null +++ b/debian/preinst @@ -0,0 +1,27 @@ +#!/bin/sh +# SPDX-FileCopyrightText: Kevin Stenzel +# SPDX-License-Identifier: GPL-3.0-or-later +set -e + +# One-time transition to Debian's service rules (7.3.6). Up to 7.3.5 the maintainer scripts +# enabled the service by hand and never recorded deb-systemd-helper state, and without that +# state `deb-systemd-helper was-enabled` answers "enabled" even for a service the admin +# disabled, so the postinst would enable it again. On an upgrade of the installed package the +# old unit and the admin's choice are still in place: record them now, before anything +# changes. Enabled -> enable (records the existing link), disabled or masked -> update-state +# (known, not enabled). Not while systemd is down (an image build, a chroot): the old postinst +# enabled the service only while systemd ran, so a missing link there is no admin decision, +# and the postinst enables it like a new installation. A reinstall from the config-files state +# ("install ") is left alone for the same reason: the old prerm disabled the service +# on remove, the admin did not. +UNIT=linuxmuster-radius.service +if [ "$1" = upgrade ] && ! deb-systemd-helper debian-installed "$UNIT"; then + if [ "$(systemctl is-enabled "$UNIT" 2>/dev/null)" = enabled ]; then + deb-systemd-helper enable "$UNIT" >/dev/null || true + elif [ -d /run/systemd/system ]; then + deb-systemd-helper update-state "$UNIT" >/dev/null || true + fi +fi + +#DEBHELPER# +exit 0 diff --git a/debian/prerm b/debian/prerm index b4449c4..8d93ecb 100644 --- a/debian/prerm +++ b/debian/prerm @@ -2,11 +2,13 @@ # SPDX-FileCopyrightText: Kevin Stenzel # SPDX-License-Identifier: GPL-3.0-or-later set -e -# Stop/disable ONLY on a real remove. On upgrade ($1=upgrade), keep the service -# RUNNING so postinst can restart it via try-restart (new code); stopping it here -# would leave it inactive after the upgrade. +# Stop ONLY on a real remove. On upgrade ($1=upgrade), keep the service RUNNING so the +# postinst restarts it (new code); stopping it here would leave it inactive after the +# upgrade. Whether it is enabled stays the admin's decision (Debian's rule, as +# dh_installsystemd does it): the postrm masks the unit while the package is removed, a +# reinstall restores the decision, a purge forgets it. Up to 7.3.5 remove also disabled it. if [ "$1" = remove ] && [ -d /run/systemd/system ]; then - systemctl disable --now linuxmuster-radius.service || true + deb-systemd-invoke stop linuxmuster-radius.service >/dev/null || true fi #DEBHELPER# exit 0 diff --git a/debian/rules b/debian/rules index 678612f..96944a0 100755 --- a/debian/rules +++ b/debian/rules @@ -40,7 +40,8 @@ override_dh_auto_clean: override_dh_strip override_dh_dwz override_dh_strip_nondeterminism override_dh_makeshlibs: @: -# The maintainer scripts handle the units by hand, unchanged since 7.3.x (the plan, §4). +# The maintainer scripts handle the unit by hand, with deb-systemd-helper and deb-systemd-invoke +# as dh_installsystemd's snippets do, because the unit stays in /lib/systemd/system. override_dh_installsystemd: @: diff --git a/docs/install.md b/docs/install.md index bf26093..8806555 100644 --- a/docs/install.md +++ b/docs/install.md @@ -52,9 +52,9 @@ lmnradius health # {"status":"ok"} Der `postinst` legt den System-User `lmnradius`, `/etc/linuxmuster-radius/{config.yml (0600, zufälliges Token),secrets,certs}` und das State-Verzeichnis als Git-Repo an (jede Instanz- Änderung ein Commit, `sudo -u lmnradius git -C /var/lib/linuxmuster-radius/instances log` — -als der Besitzer `lmnradius`: root selbst lehnt git dort mit „dubious ownership“ ab) und startet -den Dienst. Das Image (`ghcr.io/faircomp/linuxmuster-radius`, **public**) wird bei `reconcile` -gezogen. +als der Besitzer `lmnradius`: root selbst lehnt git dort mit „dubious ownership“ ab), aktiviert +und startet den Dienst. Das Image (`ghcr.io/faircomp/linuxmuster-radius`, **public**) wird bei +`reconcile` gezogen. *(Optionale Härtung: `deploy/docker-socket-proxy.yml` starten und `docker_host: "tcp://127.0.0.1:2375"` in `config.yml` setzen.)* ## 2. Auf dem linuxmuster-DC — AD vorbereiten @@ -236,8 +236,11 @@ gegen jede SSID. Ubuntus Build kennt kein `-d` (die Ausgabe ist ohne bereits vol ## 9. Updates (alles über den `.deb`) ```bash -sudo apt upgrade # neues .deb -> postinst: try-restart + 'lmnradius update-all' +sudo apt upgrade # neues .deb -> postinst: Neustart + 'lmnradius update-all' ``` +Das gilt, solange der Dienst aktiviert ist oder noch läuft: ein mit `systemctl disable --now` +abgeschalteter Dienst bleibt aus, und die Instanzen werden nicht aktualisiert +([operations.md](operations.md#dienst-abgeschaltet-lassen)). > **Upgrade von 7.3.0 oder älter — ein Pflichtschritt:** Instanzen aus diesen Versionen > prüfen das DC-Zertifikat der LDAPS-Verbindung **nicht** (Sicherheitsbefund, siehe diff --git a/docs/operations.md b/docs/operations.md index ec8c7d0..f3cfa17 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -23,8 +23,9 @@ systemctl status linuxmuster-radius # sollte "active" sein ``` Die `postinst` legt den Systembenutzer `lmnradius` an (in der Gruppe `docker`), erzeugt -ein **zufälliges API-Token** in `/etc/linuxmuster-radius/config.yml` (`0600`) und startet -den Dienst — gebunden an **`127.0.0.1:8080`**. Verzeichnisse: `secrets_dir` +ein **zufälliges API-Token** in `/etc/linuxmuster-radius/config.yml` (`0600`), aktiviert und +startet den Dienst — gebunden an **`127.0.0.1:8080`**; danach bleibt es bei der Entscheidung +des Admins ([Dienst abgeschaltet lassen](#dienst-abgeschaltet-lassen)). Verzeichnisse: `secrets_dir` (`/etc/linuxmuster-radius/secrets`, `0700`), `certs_dir` (`/etc/linuxmuster-radius/certs`, `0700`), `instances_dir` (`/var/lib/linuxmuster-radius/instances`, als Git-Repo = Change-Log: jedes `create`/`set-ldap-ca`/`rm` ist ein Commit, `sudo -u lmnradius git -C @@ -42,7 +43,7 @@ ist das Repo nicht zu retten, `.git` beiseite legen und die `postinst` erneut la `mv /var/lib/linuxmuster-radius/instances/.git /root/instances-git.kaputt && dpkg-reconfigure linuxmuster-radius` (als root). Sie legt ein neues Repo an und übernimmt die vorhandenen Datensätze in einem Import-Commit; die alte Historie bleibt im beiseitegelegten Verzeichnis. Der -Dienst wird dabei neu gestartet (wie bei einem Upgrade). +Dienst wird dabei neu gestartet (wie bei einem Upgrade; ein abgeschalteter Dienst bleibt aus). ## Erstinbetriebnahme (einmalig) @@ -178,8 +179,41 @@ Das Update zieht den neuen Digest, ersetzt den Container, wartet auf `healthy` ( Trust **und** radiusd erreichbar) und **rollt bei Fehler automatisch zurück** — die Schule bleibt online. Welcher Digest in Produktion gehört, entscheidet ein **gemergter Digest-Bump-PR** (nie Auto-Merge; von Hand, solange Renovate abgeschaltet ist). Bei einem **`.deb`-Upgrade** ruft die `postinst` -automatisch `update-all` auf (best-effort; Instanzen auf dem Default werden übersprungen, -die apt-Transaktion scheitert daran nie). +automatisch `update-all` auf, wenn der Dienst nach dem Upgrade läuft (best-effort; Instanzen auf +dem Default werden übersprungen, die apt-Transaktion scheitert daran nie). Einen abgeschalteten +Dienst startet sie dafür nicht ([Dienst abgeschaltet lassen](#dienst-abgeschaltet-lassen)). + +## Dienst abgeschaltet lassen + +Ab 7.3.6 behandelt das Paket seinen Dienst nach den Debian-Regeln (`deb-systemd-helper` und +`deb-systemd-invoke`, wie Pakete mit dh_installsystemd): eine Neuinstallation aktiviert und +startet `linuxmuster-radius`, danach behalten Upgrades, was der Admin entschieden hat. + +- **Abschalten und aus lassen:** `systemctl disable --now linuxmuster-radius`. Upgrades, + Neuinstallationen derselben Version und `dpkg-reconfigure` lassen ihn abgeschaltet und + gestoppt, aktualisieren die Instanzen nicht und schreiben eine Zeile in die apt-Ausgabe: + `linuxmuster-radius: the service is disabled and not running, instances not updated; run + 'lmnradius update-all' after starting it`. `systemctl stop` allein reicht nicht: das nächste + Upgrade startet einen aktivierten Dienst wieder. +- **Die RADIUS-Container sind getrennt:** sie sind Docker-Container (`unless-stopped`) und + laufen ohne die Control-Plane weiter. Sollen auch sie aus sein, vorher + `lmnradius stop ` (braucht den laufenden Dienst). +- **Wieder einschalten:** `systemctl enable --now linuxmuster-radius`, danach + `lmnradius update-all` für die Instanz-Updates, die die Upgrades ausgelassen haben. +- **Abgeschaltet, läuft aber noch** (`systemctl disable` ohne `--now`): ein Upgrade startet ihn + mit dem neuen Code neu und aktualisiert die Instanzen; er bleibt abgeschaltet. +- **Maskiert** (`systemctl mask`): das Paket lässt ihn in Ruhe. +- **Entfernen und neu installieren:** `apt remove` stoppt den Dienst nur und behält die + Entscheidung (die Unit bleibt maskiert, solange das Paket entfernt ist); eine Neuinstallation + stellt sie wieder her. `apt purge` vergisst sie: die nächste Installation ist eine neue, + aktiviert und gestartet. Nach dem Entfernen von 7.3.5 oder älter ist eine Neuinstallation + ebenfalls eine neue (diese Versionen haben den Dienst beim Entfernen abgeschaltet). +- **Das erste Upgrade auf 7.3.6** übernimmt einmalig den Zustand, in dem der Dienst in diesem + Moment ist: 7.3.5 und älter haben ihn nicht festgehalten. Aktiviert bleibt aktiviert, + abgeschaltet oder maskiert bleibt so. +- **Downgrade auf 7.3.5 oder älter:** diese Version aktiviert und startet den Dienst wieder. +- **Ohne laufendes systemd** (Image-Bau, chroot) aktiviert eine Neuinstallation den Dienst nur; + er startet beim nächsten Boot. ## Beobachten From c0bce3b5464fba4dc186a53a2c98bbbecbea0aed Mon Sep 17 00:00:00 2001 From: Kevin Stenzel Date: Mon, 28 Sep 2026 15:56:45 +0200 Subject: [PATCH 2/5] test(ci): upgrade-smoke keeps a service the admin disabled A permanent case in upgrade-smoke (ci.yml and release.yml, same step in both, no new job, so the required checks stay as they are): purge, install the published release, `systemctl disable --now`, then upgrade to the built package twice. After each upgrade the unit is disabled and inactive, the journal shows no start since the upgrade began, and apt printed the "instances not updated" line; afterwards deb-systemd-helper holds the recorded state. The fast tier shellchecks debian/preinst too. --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++++++++++--- .github/workflows/release.yml | 42 +++++++++++++++++++++++++++++++-- 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc27edc..2dabc30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,7 +107,7 @@ jobs: sudo apt-get update -qq && sudo apt-get install -y -qq shellcheck shellcheck --severity=warning \ image/*.sh scripts/*.sh scripts/tests/*.sh packaging/*.sh \ - debian/postinst debian/prerm debian/postrm + debian/preinst debian/postinst debian/prerm debian/postrm - name: reuse (license compliance) run: reuse lint @@ -548,8 +548,8 @@ jobs: # The upgrade path really ran and did not silently no-op. Two independent # proofs: dpkg unpacked OVER the installed version, and the service was # restarted -- prerm deliberately leaves it running on upgrade, and the only - # thing that restarts it is `systemctl try-restart` inside the postinst's - # `if [ -n "${2:-}" ]` branch, which exists only when dpkg passes an old version. + # thing that restarts it is `deb-systemd-invoke restart` in the postinst, which it + # runs instead of `start` only when dpkg passes an old version (`${2:-}`). grep -qE 'Unpacking linuxmuster-radius \([^)]+\) over \([^)]+\)' upgrade.log # dpkg's own record of the action, independent of apt's wording: exactly this # step, from the released version to the built one (a reinstall of an equal version @@ -625,6 +625,44 @@ jobs: sudo apt-get -f install -s | grep -q '0 newly installed' test -s /var/lib/dpkg/info/linuxmuster-radius.md5sums test -z "$(sudo dpkg --verify linuxmuster-radius)" + # Debian's rule from 7.3.6 on: an upgrade keeps a service the admin switched off. Once + # more from the published release, which never recorded deb-systemd-helper state (so this + # is the preinst's one-time transition), then a second time on top: the recorded state + # must hold. + # The disabled service is neither started for a moment nor used for the instance update, and + # apt shows the one line that says so. + - name: A service disabled before the upgrade stays disabled and stopped + if: steps.prev.outputs.skip != '1' + run: | + set -eux + set -o pipefail + P=linuxmuster-radius + U=$P.service + STATE=/var/lib/systemd/deb-systemd-helper-enabled/$U.dsh-also + sudo apt-get purge -y linuxmuster-radius + test ! -e "$STATE" # purge forgot the state: the release starts from scratch + sudo apt-get install -y ./previous/*.deb + test "$(systemctl is-enabled $U)" = enabled + sudo systemctl disable --now $U + test "$(systemctl is-active $U || true)" = inactive + for pass in 1 2; do + cursor="$(sudo journalctl -q -n 0 --show-cursor | sed -n 's/^-- cursor: //p')" + test -n "$cursor" + sudo apt-get install -y --reinstall --allow-downgrades ./packages/*.deb 2>&1 \ + | tee "disabled-$pass.log" + grep -E 'Unpacking linuxmuster-radius \([^)]+\) over \([^)]+\)' "disabled-$pass.log" + test "$(systemctl is-enabled $U || true)" = disabled + test "$(systemctl is-active $U || true)" = inactive + test "$(sudo journalctl -q --no-pager --after-cursor="$cursor" -u $U \ + | grep -c -F 'Started ' || true)" = 0 + grep -F "$P: the service is disabled and not running, instances not updated" \ + "disabled-$pass.log" + done + test -e "$STATE" # the transition recorded the admin's decision + test -z "$(dpkg --audit)" + echo "### disabled before the upgrade: disabled and stopped after two upgrades" \ + >> "$GITHUB_STEP_SUMMARY" + - name: Journal of the control plane (always, for the record) if: always() && steps.prev.outputs.skip != '1' run: sudo journalctl -u linuxmuster-radius.service --no-pager | tail -60 || true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8592db4..fc2049b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -453,8 +453,8 @@ jobs: # The upgrade path really ran and did not silently no-op. Two independent # proofs: dpkg unpacked OVER the installed version, and the service was # restarted -- prerm deliberately leaves it running on upgrade, and the only - # thing that restarts it is `systemctl try-restart` inside the postinst's - # `if [ -n "${2:-}" ]` branch, which exists only when dpkg passes an old version. + # thing that restarts it is `deb-systemd-invoke restart` in the postinst, which it + # runs instead of `start` only when dpkg passes an old version (`${2:-}`). grep -qE 'Unpacking linuxmuster-radius \([^)]+\) over \([^)]+\)' upgrade.log # dpkg's own record of the action, independent of apt's wording: exactly this # step, from the released version to the built one (a reinstall of an equal version @@ -530,6 +530,44 @@ jobs: sudo apt-get -f install -s | grep -q '0 newly installed' test -s /var/lib/dpkg/info/linuxmuster-radius.md5sums test -z "$(sudo dpkg --verify linuxmuster-radius)" + # Debian's rule from 7.3.6 on: an upgrade keeps a service the admin switched off. Once + # more from the published release, which never recorded deb-systemd-helper state (so this + # is the preinst's one-time transition), then a second time on top: the recorded state + # must hold. + # The disabled service is neither started for a moment nor used for the instance update, and + # apt shows the one line that says so. + - name: A service disabled before the upgrade stays disabled and stopped + if: steps.prev.outputs.skip != '1' + run: | + set -eux + set -o pipefail + P=linuxmuster-radius + U=$P.service + STATE=/var/lib/systemd/deb-systemd-helper-enabled/$U.dsh-also + sudo apt-get purge -y linuxmuster-radius + test ! -e "$STATE" # purge forgot the state: the release starts from scratch + sudo apt-get install -y ./previous/*.deb + test "$(systemctl is-enabled $U)" = enabled + sudo systemctl disable --now $U + test "$(systemctl is-active $U || true)" = inactive + for pass in 1 2; do + cursor="$(sudo journalctl -q -n 0 --show-cursor | sed -n 's/^-- cursor: //p')" + test -n "$cursor" + sudo apt-get install -y --reinstall --allow-downgrades ./packages/*.deb 2>&1 \ + | tee "disabled-$pass.log" + grep -E 'Unpacking linuxmuster-radius \([^)]+\) over \([^)]+\)' "disabled-$pass.log" + test "$(systemctl is-enabled $U || true)" = disabled + test "$(systemctl is-active $U || true)" = inactive + test "$(sudo journalctl -q --no-pager --after-cursor="$cursor" -u $U \ + | grep -c -F 'Started ' || true)" = 0 + grep -F "$P: the service is disabled and not running, instances not updated" \ + "disabled-$pass.log" + done + test -e "$STATE" # the transition recorded the admin's decision + test -z "$(dpkg --audit)" + echo "### disabled before the upgrade: disabled and stopped after two upgrades" \ + >> "$GITHUB_STEP_SUMMARY" + - name: Journal of the control plane (always, for the record) if: always() && steps.prev.outputs.skip != '1' run: sudo journalctl -u linuxmuster-radius.service --no-pager | tail -60 || true From 2ee18d851068a57daa771ce63387ea01e45c5ecf Mon Sep 17 00:00:00 2001 From: Kevin Stenzel Date: Mon, 28 Sep 2026 16:29:25 +0200 Subject: [PATCH 3/5] fix(debian): postrm calls deb-systemd-helper without an -x guard lintian warned command-with-path-in-maintainer-script for the `[ -x /usr/bin/deb-systemd-helper ]` tests (dh_installsystemd's own snippets are exempt as generated code). init-system-helpers is Essential on Ubuntu 24.04, and `|| true` already covers a missing command. --- debian/postrm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/debian/postrm b/debian/postrm index 624a714..839e748 100644 --- a/debian/postrm +++ b/debian/postrm @@ -6,17 +6,15 @@ if [ -d /run/systemd/system ]; then systemctl daemon-reload || true fi # The admin's enable/disable decision survives a remove (the unit stays masked until the -# postinst of a reinstall unmasks it) and is forgotten on purge; Debian's rule, as -# dh_installsystemd does it. -if [ "$1" = remove ] && [ -x /usr/bin/deb-systemd-helper ]; then +# postinst of a reinstall unmasks it) and is forgotten on purge. deb-systemd-helper comes +# with init-system-helpers, which is Essential. +if [ "$1" = remove ]; then deb-systemd-helper mask linuxmuster-radius.service >/dev/null || true fi # Deliberately do NOT delete config/state + venv on remove (only on purge). if [ "$1" = "purge" ]; then - if [ -x /usr/bin/deb-systemd-helper ]; then - deb-systemd-helper purge linuxmuster-radius.service >/dev/null || true - deb-systemd-helper unmask linuxmuster-radius.service >/dev/null || true - fi + deb-systemd-helper purge linuxmuster-radius.service >/dev/null || true + deb-systemd-helper unmask linuxmuster-radius.service >/dev/null || true rm -rf /opt/linuxmuster-radius rm -rf /etc/linuxmuster-radius /var/lib/linuxmuster-radius fi From f1a1ebc799517ae85fc8b4dfbae63bb296c9b990 Mon Sep 17 00:00:00 2001 From: Kevin Stenzel Date: Mon, 28 Sep 2026 16:45:02 +0200 Subject: [PATCH 4/5] fix(debian): remove/purge as debhelper 13.14's dh_installsystemd snippets debhelper 13.10 stopped masking system units on package removal (Debian #1021027: the mask only kept a left-over sysv init script from starting, and these packages ship none), and its purge snippet runs only `deb-systemd-helper purge`. Ubuntu 24.04 has 13.14, so the postrm no longer masks on remove and no longer unmasks on purge. What the 13.14 snippets still do stays: postinst `deb-systemd-helper unmask` (lifts only a mask deb-systemd-helper set itself) followed by enable/update-state, prerm `deb-systemd-invoke stop` on remove only, postrm `deb-systemd-helper purge` on purge (the daemon-reload stays as before). The decision still survives remove + reinstall: the prerm only stops the service and the enable link and the recorded state stay until purge. docs/operations.md no longer says the unit stays masked while removed. --- debian/postinst | 2 ++ debian/postrm | 11 ++++------- debian/prerm | 4 ++-- docs/operations.md | 8 ++++---- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/debian/postinst b/debian/postinst index 6cb6d95..b515e3c 100644 --- a/debian/postinst +++ b/debian/postinst @@ -120,6 +120,8 @@ chmod -R go-w /opt/linuxmuster-radius # server coming from 7.3.5 or older. Without a running systemd (image build, chroot) only the # links are made and the service starts with the next boot. UNIT=linuxmuster-radius.service +# unmask as dh_installsystemd still does: it lifts only a mask deb-systemd-helper set itself +# (older debhelper masked on remove), never one of the admin. deb-systemd-helper unmask "$UNIT" >/dev/null || true if deb-systemd-helper --quiet was-enabled "$UNIT"; then deb-systemd-helper enable "$UNIT" >/dev/null || true diff --git a/debian/postrm b/debian/postrm index 839e748..14c243f 100644 --- a/debian/postrm +++ b/debian/postrm @@ -5,16 +5,13 @@ set -e if [ -d /run/systemd/system ]; then systemctl daemon-reload || true fi -# The admin's enable/disable decision survives a remove (the unit stays masked until the -# postinst of a reinstall unmasks it) and is forgotten on purge. deb-systemd-helper comes -# with init-system-helpers, which is Essential. -if [ "$1" = remove ]; then - deb-systemd-helper mask linuxmuster-radius.service >/dev/null || true -fi # Deliberately do NOT delete config/state + venv on remove (only on purge). if [ "$1" = "purge" ]; then + # The admin's enable/disable decision survives a remove (the prerm only stops the service) + # and is forgotten here, as debhelper 13.14's dh_installsystemd snippet does it (no mask on + # remove, no unmask on purge since debhelper 13.10). deb-systemd-helper comes with + # init-system-helpers, which is Essential. deb-systemd-helper purge linuxmuster-radius.service >/dev/null || true - deb-systemd-helper unmask linuxmuster-radius.service >/dev/null || true rm -rf /opt/linuxmuster-radius rm -rf /etc/linuxmuster-radius /var/lib/linuxmuster-radius fi diff --git a/debian/prerm b/debian/prerm index 8d93ecb..197b292 100644 --- a/debian/prerm +++ b/debian/prerm @@ -5,8 +5,8 @@ set -e # Stop ONLY on a real remove. On upgrade ($1=upgrade), keep the service RUNNING so the # postinst restarts it (new code); stopping it here would leave it inactive after the # upgrade. Whether it is enabled stays the admin's decision (Debian's rule, as -# dh_installsystemd does it): the postrm masks the unit while the package is removed, a -# reinstall restores the decision, a purge forgets it. Up to 7.3.5 remove also disabled it. +# dh_installsystemd does it): a reinstall after a remove restores it, a purge forgets it +# (postrm). Up to 7.3.5 remove also disabled it. if [ "$1" = remove ] && [ -d /run/systemd/system ]; then deb-systemd-invoke stop linuxmuster-radius.service >/dev/null || true fi diff --git a/docs/operations.md b/docs/operations.md index f3cfa17..c979320 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -204,10 +204,10 @@ startet `linuxmuster-radius`, danach behalten Upgrades, was der Admin entschiede mit dem neuen Code neu und aktualisiert die Instanzen; er bleibt abgeschaltet. - **Maskiert** (`systemctl mask`): das Paket lässt ihn in Ruhe. - **Entfernen und neu installieren:** `apt remove` stoppt den Dienst nur und behält die - Entscheidung (die Unit bleibt maskiert, solange das Paket entfernt ist); eine Neuinstallation - stellt sie wieder her. `apt purge` vergisst sie: die nächste Installation ist eine neue, - aktiviert und gestartet. Nach dem Entfernen von 7.3.5 oder älter ist eine Neuinstallation - ebenfalls eine neue (diese Versionen haben den Dienst beim Entfernen abgeschaltet). + Entscheidung; eine Neuinstallation stellt sie wieder her. `apt purge` vergisst sie: die + nächste Installation ist eine neue, aktiviert und gestartet. Nach dem Entfernen von 7.3.5 oder + älter ist eine Neuinstallation ebenfalls eine neue (diese Versionen haben den Dienst beim + Entfernen abgeschaltet). - **Das erste Upgrade auf 7.3.6** übernimmt einmalig den Zustand, in dem der Dienst in diesem Moment ist: 7.3.5 und älter haben ihn nicht festgehalten. Aktiviert bleibt aktiviert, abgeschaltet oder maskiert bleibt so. From 35bcef8570922dedd88457d479e22785b3c93fba Mon Sep 17 00:00:00 2001 From: Kevin Stenzel Date: Mon, 28 Sep 2026 17:37:08 +0200 Subject: [PATCH 5/5] docs(changelog): name the offline exception of the transition; update-all ran on upgrades From the cold verification (linuxmusterDEV work/verification/ cold-dienst-zustand.md), text only: * The changelog and docs/operations.md now state the one exception the preinst makes on purpose: when the one-time transition runs without a running systemd (an image build, a chroot), a service without an enable link is treated like a new installation and enabled, because the old postinst never enabled it offline. Online upgrades and every later upgrade keep an admin-disabled service off. * The old postinst updated the instances on every upgrade (and on dpkg-reconfigure, which also passes the installed version), never on a new installation; the changelog no longer says "every install". The entry keeps its version and date. --- debian/changelog | 10 ++++++++-- docs/operations.md | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 94acd78..5576199 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,9 @@ linuxmuster-radius (7.3.6) lmn73; urgency=medium * Upgrades respect a service the admin switched off. Up to 7.3.5 every install, upgrade and dpkg-reconfigure enabled and started - linuxmuster-radius.service again, and updated the RADIUS instances - through it (lmnradius update-all). + linuxmuster-radius.service again, and every upgrade (and + dpkg-reconfigure) updated the RADIUS instances through it + (lmnradius update-all). The package now follows Debian's rules (deb-systemd-helper and deb-systemd-invoke, as packages built with dh_installsystemd do): a new installation enables and starts the service; after that, upgrades keep @@ -17,6 +18,11 @@ linuxmuster-radius (7.3.6) lmn73; urgency=medium * The first upgrade to 7.3.6 takes over the state the service is in at that moment (the new preinst records it once), because 7.3.5 and older kept no record of it: a service that is disabled then stays disabled. + One exception: if this first upgrade runs without a running systemd + (an image build, a chroot), a service without an enable link is + treated like a new installation and enabled, because 7.3.5 and older + never enabled it offline. Upgrades with systemd running, and every + later upgrade, keep a service the admin disabled off. * Removing the package now only stops the service; it is no longer disabled. The decision is kept while the package is removed and applies again when it is reinstalled; purge forgets it. Reinstalling after diff --git a/docs/operations.md b/docs/operations.md index c979320..afad428 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -210,7 +210,11 @@ startet `linuxmuster-radius`, danach behalten Upgrades, was der Admin entschiede Entfernen abgeschaltet). - **Das erste Upgrade auf 7.3.6** übernimmt einmalig den Zustand, in dem der Dienst in diesem Moment ist: 7.3.5 und älter haben ihn nicht festgehalten. Aktiviert bleibt aktiviert, - abgeschaltet oder maskiert bleibt so. + abgeschaltet oder maskiert bleibt so. Eine Ausnahme: läuft dieses erste Upgrade ohne + laufendes systemd (Image-Bau, chroot), wird ein Dienst ohne Aktivierungs-Link wie bei einer + Neuinstallation behandelt und aktiviert, weil 7.3.5 und älter ihn offline nie aktiviert haben. + Upgrades mit laufendem systemd und jedes spätere Upgrade lassen einen vom Admin abgeschalteten + Dienst aus. - **Downgrade auf 7.3.5 oder älter:** diese Version aktiviert und startet den Dienst wieder. - **Ohne laufendes systemd** (Image-Bau, chroot) aktiviert eine Neuinstallation den Dienst nur; er startet beim nächsten Boot.