diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f00a3bd0..abe3ca75 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: diff --git a/changelog/highlights/317.json b/changelog/highlights/317.json new file mode 100644 index 00000000..462847c7 --- /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 abf22963..809b0f13 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 be186a60..e5764b86 100644 --- a/installer/CHANGELOG.md +++ b/installer/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## v0.4.1 (2026-12-04) + +### 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) ### Features diff --git a/installer/VERSION b/installer/VERSION index fb7a04cf..5aff472d 100644 --- a/installer/VERSION +++ b/installer/VERSION @@ -1 +1 @@ -v0.4.0 +v0.4.1 diff --git a/installer/internal/host/packages.go b/installer/internal/host/packages.go index 1ded19ac..f7164c83 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 -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) +} + // 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 dea5e310..8608790a 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 -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) + } + } + if strings.Contains(cmd, "chmod") { + t.Errorf("listing command still runs chmod as the SSH user:\n%s", cmd) + } +} diff --git a/scripts/bootstrap/CHANGELOG.md b/scripts/bootstrap/CHANGELOG.md index 3e30278e..14f2ff8b 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/scripts/bootstrap/VERSION b/scripts/bootstrap/VERSION index fb7a04cf..5aff472d 100644 --- a/scripts/bootstrap/VERSION +++ b/scripts/bootstrap/VERSION @@ -1 +1 @@ -v0.4.0 +v0.4.1 diff --git a/scripts/bootstrap/lib/wheels.sh b/scripts/bootstrap/lib/wheels.sh index a73fb133..94d23e1a 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 diff --git a/services/apsystems_ez1/CHANGELOG.md b/services/apsystems_ez1/CHANGELOG.md index 84292ef4..bf9627a2 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 49a51a0a..57cec07a 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 650092ee..8a118551 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 4e2bc75d..482bdab6 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 8ab0308e..dd1e307a 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)