Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions changelog/highlights/317.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"de": {
"*": "Installer übernimmt ein root-eigenes Wheels-Verzeichnis vor dem Ablegen"
},
"en": {
"*": "Claim a root-owned wheels directory before staging"
}
}
1 change: 1 addition & 0 deletions dashboard/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions installer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion installer/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.4.0
v0.4.1
23 changes: 20 additions & 3 deletions installer/internal/host/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
22 changes: 22 additions & 0 deletions installer/internal/host/packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"os"
"path/filepath"
"strings"
"testing"
"time"

Expand All @@ -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 })
Expand Down Expand Up @@ -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)
}
}
6 changes: 6 additions & 0 deletions scripts/bootstrap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.4.0
v0.4.1
4 changes: 3 additions & 1 deletion scripts/bootstrap/lib/wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion services/apsystems_ez1/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

### Chores

- **release:** prepare v0.12.0 (304be24)
- **release:** prepare v0.12.0 (8b39d99)

## v0.4.5 (2026-11-15)

Expand Down
2 changes: 1 addition & 1 deletion services/automation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

### Chores

- **release:** prepare v0.12.0 (7a20c16)
- **release:** prepare v0.12.0 (8b39d99)

## v0.7.2 (2026-10-27)

Expand Down
2 changes: 1 addition & 1 deletion services/battery_soc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

### Chores

- **release:** prepare v0.12.0 (7a20c16)
- **release:** prepare v0.12.0 (8b39d99)

## v0.4.8 (2026-10-21)

Expand Down
2 changes: 1 addition & 1 deletion services/shelly/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

### Chores

- **release:** prepare v0.12.0 (304be24)
- **release:** prepare v0.12.0 (8b39d99)

## v0.4.5 (2026-11-15)

Expand Down
2 changes: 1 addition & 1 deletion services/tuya_mqtt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

### Chores

- **release:** prepare v0.12.0 (304be24)
- **release:** prepare v0.12.0 (8b39d99)

## v0.4.5 (2026-11-15)

Expand Down
Loading