Move the supported systemd path to two services: an owner-user bangerd for orchestration and a narrow root helper for bridge/tap, NAT/resolver, dm/loop, and Firecracker ownership. This removes repeated sudo from daily vm and image flows without leaving the general daemon running as root. Add install metadata, system install/status/restart/uninstall commands, and a system-owned runtime layout. Keep user SSH/config material in the owner home, lock file_sync to the owner home, and move daemon known_hosts handling out of the old root-owned control path. Route privileged lifecycle steps through typed privilegedOps calls, harden the two systemd units, and rewrite smoke plus docs around the supported service model. Verified with make build, make test, make lint, and make smoke on the supported systemd host path.
39 lines
852 B
Go
39 lines
852 B
Go
package installmeta
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestSaveLoadRoundTrip(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "install.toml")
|
|
want := Metadata{
|
|
OwnerUser: "dev",
|
|
OwnerUID: 1000,
|
|
OwnerGID: 1000,
|
|
OwnerHome: "/home/dev",
|
|
InstalledAt: time.Unix(1710000000, 0).UTC(),
|
|
Version: "v1.2.3",
|
|
Commit: "abc123",
|
|
BuiltAt: "2026-04-23T00:00:00Z",
|
|
}
|
|
|
|
if err := Save(path, want); err != nil {
|
|
t.Fatalf("Save: %v", err)
|
|
}
|
|
got, err := Load(path)
|
|
if err != nil {
|
|
t.Fatalf("Load: %v", err)
|
|
}
|
|
if got != want {
|
|
t.Fatalf("Load() = %+v, want %+v", got, want)
|
|
}
|
|
}
|
|
|
|
func TestValidateRejectsMissingOwner(t *testing.T) {
|
|
err := Metadata{OwnerUID: 1000, OwnerGID: 1000, OwnerHome: "/home/dev"}.Validate()
|
|
if err == nil {
|
|
t.Fatal("Validate() = nil, want missing owner_user error")
|
|
}
|
|
}
|