From 8bfba67029b23df7680deb2d6dcc162829b92ce0 Mon Sep 17 00:00:00 2001 From: DevSimon <73778205+Developer-Simon@users.noreply.github.com> Date: Fri, 4 Dec 2026 20:36:18 +0100 Subject: [PATCH 1/6] fix(installer): claim a root-owned wheels directory before staging Step 50 runs as root and creates /var/lib/energy-node-installer/wheels when it runs before the host has staged any wheels, for example after an updater run. The host then ran mkdir/chmod as the SSH user and failed with "chmod: Operation not permitted". The listing now takes ownership of the directory and its top-level files with sudo, like the state directory itself. Co-Authored-By: Claude Sonnet 5.5 --- installer/internal/host/packages.go | 23 ++++++++++++++++++++--- installer/internal/host/packages_test.go | 22 ++++++++++++++++++++++ scripts/bootstrap/lib/wheels.sh | 4 +++- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/installer/internal/host/packages.go b/installer/internal/host/packages.go index 1ded19acf..65f57cf0f 100644 --- a/installer/internal/host/packages.go +++ b/installer/internal/host/packages.go @@ -152,15 +152,32 @@ func (h *Host) prepareSelection(manifest *bundle.Manifest) *selection.Selection // replace it; production runs defaultStagePackages. var stagePackages = defaultStagePackages +// stageSudo prefixes the commands that claim remoteDir for the connecting +// user. Tests replace it with "env", because the test SSH server runs as an +// ordinary user without sudo. +var stageSudo = "sudo" + +// stageListingCommand claims remoteDir for the connecting user and prints +// the SHA-256 of every file at its top level. Step 50 runs as root and may +// have created the wheels directory and its files first (updater runs or +// older installers), so a plain mkdir/chmod as the SSH user fails there. +// The parent state directory already belongs to that user, so owning the +// subdirectory grants nothing new. +func stageListingCommand(remoteDir string) string { + return fmt.Sprintf( + `%[2]s install -d -o "$(id -un)" -g "$(id -un)" -m 0755 %[1]s && `+ + `%[2]s find %[1]s -maxdepth 1 -type f ! -user "$(id -un)" -exec chown "$(id -un):$(id -un)" {} + && `+ + `cd %[1]s && find . -maxdepth 1 -type f -print0 | xargs -0 -r sha256sum`, + transport.ShellQuote(remoteDir), stageSudo) +} + // defaultStagePackages makes remoteDir hold exactly the files pkgs names: a // file whose SHA-256 on the node already matches the pin is left alone, // a missing or differing one is uploaded, and every other file in remoteDir // is removed. Only the top level of remoteDir is touched. func defaultStagePackages(ctx context.Context, client *transport.Client, remoteDir string, pkgs []bundlesource.LocalPackage, progress func(done, total int64)) error { quoted := transport.ShellQuote(remoteDir) - listing := fmt.Sprintf( - "mkdir -p %[1]s && chmod 0755 %[1]s && cd %[1]s && find . -maxdepth 1 -type f -print0 | xargs -0 -r sha256sum", - quoted) + listing := stageListingCommand(remoteDir) var stdout, stderr strings.Builder if err := client.Run(ctx, listing, &stdout, &stderr); err != nil { return fmt.Errorf("listing %s: %w (stderr: %s)", remoteDir, err, stderr.String()) diff --git a/installer/internal/host/packages_test.go b/installer/internal/host/packages_test.go index dea5e3102..e84580304 100644 --- a/installer/internal/host/packages_test.go +++ b/installer/internal/host/packages_test.go @@ -7,6 +7,7 @@ import ( "errors" "os" "path/filepath" + "strings" "testing" "time" @@ -25,6 +26,9 @@ func dialPackagesTest(t *testing.T) *transport.Client { if _, ok := transporttest.SFTPServerPath(); !ok { t.Skip("no sftp-server binary found; install openssh-sftp-server to run this test") } + origSudo := stageSudo + stageSudo = "env" + t.Cleanup(func() { stageSudo = origSudo }) sshd := transporttest.Start(t) store := transport.NewHostKeyStore(filepath.Join(t.TempDir(), "known_hosts")) callback, err := store.Callback(func(string, string) (bool, error) { return true, nil }) @@ -314,3 +318,21 @@ func TestPackageChoiceIsRememberedForTheSession(t *testing.T) { t.Errorf("remembered choices = %v, want caddy skip", h.packageChoices) } } + +// Step 50 runs as root and may create the wheels directory and its files +// before the host ever stages into it. The listing must claim both with sudo, +// a plain chmod as the SSH user fails with "Operation not permitted". +func TestStageListingClaimsRootOwnedDirWithSudo(t *testing.T) { + cmd := stageListingCommand("/var/lib/energy-node-installer/wheels") + for _, want := range []string{ + `sudo install -d -o "$(id -un)" -g "$(id -un)" -m 0755 '/var/lib/energy-node-installer/wheels'`, + `sudo find '/var/lib/energy-node-installer/wheels' -maxdepth 1 -type f ! -user "$(id -un)" -exec chown "$(id -un):$(id -un)" {} +`, + } { + if !strings.Contains(cmd, want) { + t.Errorf("listing command lacks %q:\n%s", want, cmd) + } + } + if strings.Contains(cmd, "chmod") { + t.Errorf("listing command still runs chmod as the SSH user:\n%s", cmd) + } +} diff --git a/scripts/bootstrap/lib/wheels.sh b/scripts/bootstrap/lib/wheels.sh index a73fb1334..94d23e1ac 100644 --- a/scripts/bootstrap/lib/wheels.sh +++ b/scripts/bootstrap/lib/wheels.sh @@ -12,7 +12,9 @@ # Dateien in EN_WHEELS_DIR ohne Festlegung werden geloescht, so kann eine # untergeschobene .whl nie in pip geraten. # -# Das Verzeichnis gehoert root (0755), die Dateien sind 0644. Das Verzeichnis +# Das Verzeichnis ist 0755, die Dateien sind 0644. Legt dieser Schritt es an, +# gehoert es root. Der Installer-Host uebernimmt es vor dem Ablegen der Wheels +# fuer das SSH-Konto, dem EN_STATE_DIR ohnehin gehoert. Das Verzeichnis # liegt unter EN_STATE_DIR und nicht im Auftragsverzeichnis, aus dem der # Updater das Bundle holt - dort haette das Dashboard-Konto Schreibrecht. # Schritte laufen als root (Updater) oder mit sudo (Installer), deshalb gehen From e8e4fdaed500bca552f65100850eb79c5cb58d72 Mon Sep 17 00:00:00 2001 From: energy-node-bot Date: Fri, 4 Dec 2026 19:44:05 +0000 Subject: [PATCH 2/6] chore(release): bump component versions --- installer/VERSION | 2 +- scripts/bootstrap/VERSION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/VERSION b/installer/VERSION index fb7a04cff..5aff472dd 100644 --- a/installer/VERSION +++ b/installer/VERSION @@ -1 +1 @@ -v0.4.0 +v0.4.1 diff --git a/scripts/bootstrap/VERSION b/scripts/bootstrap/VERSION index fb7a04cff..5aff472dd 100644 --- a/scripts/bootstrap/VERSION +++ b/scripts/bootstrap/VERSION @@ -1 +1 @@ -v0.4.0 +v0.4.1 From 38898bf1e65ef2541d56a82768c22cc1c081b044 Mon Sep 17 00:00:00 2001 From: energy-node-bot Date: Fri, 4 Dec 2026 19:45:06 +0000 Subject: [PATCH 3/6] docs(changelog): update changelogs --- changelog/highlights/317.json | 8 ++++++++ dashboard/CHANGELOG.md | 1 + installer/CHANGELOG.md | 6 ++++++ scripts/bootstrap/CHANGELOG.md | 6 ++++++ services/apsystems_ez1/CHANGELOG.md | 2 +- services/automation/CHANGELOG.md | 2 +- services/battery_soc/CHANGELOG.md | 2 +- services/shelly/CHANGELOG.md | 2 +- services/tuya_mqtt/CHANGELOG.md | 2 +- 9 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 changelog/highlights/317.json diff --git a/changelog/highlights/317.json b/changelog/highlights/317.json new file mode 100644 index 000000000..462847c74 --- /dev/null +++ b/changelog/highlights/317.json @@ -0,0 +1,8 @@ +{ + "de": { + "*": "Installer übernimmt ein root-eigenes Wheels-Verzeichnis vor dem Ablegen" + }, + "en": { + "*": "Claim a root-owned wheels directory before staging" + } +} diff --git a/dashboard/CHANGELOG.md b/dashboard/CHANGELOG.md index abf229636..809b0f13e 100644 --- a/dashboard/CHANGELOG.md +++ b/dashboard/CHANGELOG.md @@ -375,6 +375,7 @@ - **automations:** correct the learning methods after the spec check (#306) (0296218) - **dashboard:** keep the Run at most field of the scenario editor in one row (#310) (9e29569) - **auth:** give existing admins the network permission (#313) (5766220) +- **release:** align the cache-bust marks with main for v0.12.0 (2ad3918) - **history:** keep proxies from compressing the event streams (#304) (0298760) - **automations:** correct the learning feature after the full review (#296) (88f3c75) - Monitoring names values without a role and links to the learning settings (#303) (29450b8) diff --git a/installer/CHANGELOG.md b/installer/CHANGELOG.md index be186a600..db27d919f 100644 --- a/installer/CHANGELOG.md +++ b/installer/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v0.4.1 (2026-12-04) + +### Fixes + +- **installer:** claim a root-owned wheels directory before staging (#317) + ## v0.4.0 (2026-11-30) ### Features diff --git a/scripts/bootstrap/CHANGELOG.md b/scripts/bootstrap/CHANGELOG.md index 3e30278e2..14f2ff8b2 100644 --- a/scripts/bootstrap/CHANGELOG.md +++ b/scripts/bootstrap/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v0.4.1 (2026-12-04) + +### Fixes + +- **installer:** claim a root-owned wheels directory before staging (#317) + ## v0.4.0 (2026-11-20) ### Features diff --git a/services/apsystems_ez1/CHANGELOG.md b/services/apsystems_ez1/CHANGELOG.md index 84292ef4b..bf9627a27 100644 --- a/services/apsystems_ez1/CHANGELOG.md +++ b/services/apsystems_ez1/CHANGELOG.md @@ -8,7 +8,7 @@ ### Chores -- **release:** prepare v0.12.0 (304be24) +- **release:** prepare v0.12.0 (8b39d99) ## v0.4.5 (2026-11-15) diff --git a/services/automation/CHANGELOG.md b/services/automation/CHANGELOG.md index 49a51a0a3..57cec07a0 100644 --- a/services/automation/CHANGELOG.md +++ b/services/automation/CHANGELOG.md @@ -32,7 +32,7 @@ ### Chores -- **release:** prepare v0.12.0 (7a20c16) +- **release:** prepare v0.12.0 (8b39d99) ## v0.7.2 (2026-10-27) diff --git a/services/battery_soc/CHANGELOG.md b/services/battery_soc/CHANGELOG.md index 650092ee9..8a1185515 100644 --- a/services/battery_soc/CHANGELOG.md +++ b/services/battery_soc/CHANGELOG.md @@ -20,7 +20,7 @@ ### Chores -- **release:** prepare v0.12.0 (7a20c16) +- **release:** prepare v0.12.0 (8b39d99) ## v0.4.8 (2026-10-21) diff --git a/services/shelly/CHANGELOG.md b/services/shelly/CHANGELOG.md index 4e2bc75d0..482bdab69 100644 --- a/services/shelly/CHANGELOG.md +++ b/services/shelly/CHANGELOG.md @@ -8,7 +8,7 @@ ### Chores -- **release:** prepare v0.12.0 (304be24) +- **release:** prepare v0.12.0 (8b39d99) ## v0.4.5 (2026-11-15) diff --git a/services/tuya_mqtt/CHANGELOG.md b/services/tuya_mqtt/CHANGELOG.md index 8ab0308ec..dd1e307ac 100644 --- a/services/tuya_mqtt/CHANGELOG.md +++ b/services/tuya_mqtt/CHANGELOG.md @@ -8,7 +8,7 @@ ### Chores -- **release:** prepare v0.12.0 (304be24) +- **release:** prepare v0.12.0 (8b39d99) ## v0.4.5 (2026-11-15) From 8a830bfdbfe335eae10e2289f2275fcfa482a0dd Mon Sep 17 00:00:00 2001 From: DevSimon <73778205+Developer-Simon@users.noreply.github.com> Date: Fri, 4 Dec 2026 20:51:59 +0100 Subject: [PATCH 4/6] ci: queue the post-merge macOS media jobs one after the other The main and prerelease runs now share one concurrency group for the macOS media end-to-end job, so they no longer wait for scarce macOS runners at the same time. PR runs keep a group per run and stay parallel. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f00a3bd0d..abe3ca753 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -184,6 +184,15 @@ jobs: name: Installer media end to end (macOS) needs: changes if: needs.changes.outputs.installer_macos == 'true' || github.event_name == 'push' + # macOS runners are scarce. The post-merge runs on main and prerelease + # share one group, so their macOS jobs queue one after the other instead + # of all waiting for a runner at once. PR runs get a group of their own + # and stay parallel. A queued job is never cancelled by a running one + # (cancel-in-progress: false), only by a newer queued job of the same + # group; "Re-run failed jobs" then starts it again. + concurrency: + group: ${{ github.event_name == 'push' && 'ci-macos-post-merge' || format('ci-macos-{0}', github.run_id) }} + cancel-in-progress: false runs-on: macos-latest timeout-minutes: 30 permissions: From 737e97f38a0c3cafe6aec129841e009fa20c20f0 Mon Sep 17 00:00:00 2001 From: DevSimon <73778205+Developer-Simon@users.noreply.github.com> Date: Fri, 4 Dec 2026 20:53:00 +0100 Subject: [PATCH 5/6] fix(installer): use the primary group when claiming the staging directory The user's primary group is not always named after the user. On the macOS runner "runner" belongs to "staff", so "install -g runner" failed. Use "id -gn" for the group instead. Co-Authored-By: Claude Sonnet 5.5 --- installer/internal/host/packages.go | 4 ++-- installer/internal/host/packages_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/installer/internal/host/packages.go b/installer/internal/host/packages.go index 65f57cf0f..f7164c838 100644 --- a/installer/internal/host/packages.go +++ b/installer/internal/host/packages.go @@ -165,8 +165,8 @@ var stageSudo = "sudo" // subdirectory grants nothing new. func stageListingCommand(remoteDir string) string { return fmt.Sprintf( - `%[2]s install -d -o "$(id -un)" -g "$(id -un)" -m 0755 %[1]s && `+ - `%[2]s find %[1]s -maxdepth 1 -type f ! -user "$(id -un)" -exec chown "$(id -un):$(id -un)" {} + && `+ + `%[2]s install -d -o "$(id -un)" -g "$(id -gn)" -m 0755 %[1]s && `+ + `%[2]s find %[1]s -maxdepth 1 -type f ! -user "$(id -un)" -exec chown "$(id -un):$(id -gn)" {} + && `+ `cd %[1]s && find . -maxdepth 1 -type f -print0 | xargs -0 -r sha256sum`, transport.ShellQuote(remoteDir), stageSudo) } diff --git a/installer/internal/host/packages_test.go b/installer/internal/host/packages_test.go index e84580304..8608790a9 100644 --- a/installer/internal/host/packages_test.go +++ b/installer/internal/host/packages_test.go @@ -325,8 +325,8 @@ func TestPackageChoiceIsRememberedForTheSession(t *testing.T) { func TestStageListingClaimsRootOwnedDirWithSudo(t *testing.T) { cmd := stageListingCommand("/var/lib/energy-node-installer/wheels") for _, want := range []string{ - `sudo install -d -o "$(id -un)" -g "$(id -un)" -m 0755 '/var/lib/energy-node-installer/wheels'`, - `sudo find '/var/lib/energy-node-installer/wheels' -maxdepth 1 -type f ! -user "$(id -un)" -exec chown "$(id -un):$(id -un)" {} +`, + `sudo install -d -o "$(id -un)" -g "$(id -gn)" -m 0755 '/var/lib/energy-node-installer/wheels'`, + `sudo find '/var/lib/energy-node-installer/wheels' -maxdepth 1 -type f ! -user "$(id -un)" -exec chown "$(id -un):$(id -gn)" {} +`, } { if !strings.Contains(cmd, want) { t.Errorf("listing command lacks %q:\n%s", want, cmd) From 9191a54a5a52c169a1f4a83236855b8489eb1170 Mon Sep 17 00:00:00 2001 From: energy-node-bot Date: Fri, 4 Dec 2026 19:54:48 +0000 Subject: [PATCH 6/6] docs(changelog): update changelogs --- installer/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/installer/CHANGELOG.md b/installer/CHANGELOG.md index db27d919f..e5764b860 100644 --- a/installer/CHANGELOG.md +++ b/installer/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fixes +- **installer:** use the primary group when claiming the staging directory (737e97f) - **installer:** claim a root-owned wheels directory before staging (#317) ## v0.4.0 (2026-11-30)