Refuse to take over a system account as one that never becomes root
mesh/merge-gate pass: builds mesh-host → ace, g14, novox, shanks; no bus step; every machine composes with the change as it did without (4 of 4 compose)
mesh/repo-check pass: its merge-check.sh passed
mesh/delivery superseded: a newer head of the same pull request

The controller cannot read a machine's user database, so a name it is given
for the agents' account (hq ADR 0266) may be a service's own; taking it over
would hand agents that service's files. Refuse it, touching nothing.
This commit is contained in:
jochen
2026-10-08 20:52:44 +02:00
parent 5fc37b44a9
commit 76f3ca12b8
2 changed files with 44 additions and 0 deletions
+29
View File
@@ -292,3 +292,32 @@ func TestTheFoundShellIsNotOverwrittenByASecondChange(t *testing.T) {
t.Errorf("given back %q, not the shell from before the mesh", l.shells["operator"])
}
}
// An account declared never to become root is never a system account taken over (novox/hq ADR 0266): the
// controller cannot tell a service's account from a free name, so the node-engine refuses it, touching nothing.
func TestARootNeverAccountIsNotASystemAccountTakenOver(t *testing.T) {
l := &logins{shells: map[string]string{}}
run := func(ctx context.Context, name string, args ...string) (string, error) {
if name == "getent" && args[len(args)-1] == "postgres" {
l.asked = append(l.asked, name+" "+strings.Join(args, " "))
return "postgres:x:70:70::/var/lib/postgres:/usr/bin/nologin\n", nil
}
return l.run(ctx, name, args...)
}
declared := func(name string) string {
return `{"declaration":1,"resources":[{"id":"claude-code.agent-account","type":"user","name":"` + name + `","root":"never"}]}`
}
report, _, err := Apply(context.Background(), archHost(t), parse(t, declared("postgres")), store.State{},
store.OriginDeclared, run, nil, nil)
if err == nil || !strings.Contains(err.Error(), "system account") {
t.Fatalf("a system account is refused as the agents' account: %v %+v", err, report)
}
if l.did("usermod") || l.did("useradd") {
t.Fatalf("nothing is changed on the refused account: %v", l.asked)
}
l.shells["agent"] = "/bin/bash" // uid 1500 in the fake: a login
if _, _, err := Apply(context.Background(), archHost(t), parse(t, declared("agent")), store.State{},
store.OriginDeclared, run, nil, nil); err != nil {
t.Fatalf("a login's account is taken: %v", err)
}
}