Fill machine facts in a user's home, so an agent account named with a home is made there
node agent-account <node> <account> [home] stored a home that nothing used: the account was created at /home/<account> while its files went to the named home (hq ADR 0266). The engine reads a user's home only when it creates the account, so an existing one is never moved.
This commit is contained in:
@@ -36,7 +36,8 @@ func TestTheAgentAccountFactFallsBackToTheOperatorAndIsNeverRootOnlyWhenItsOwn(t
|
|||||||
// The agent's module, in the shape the catalogue's declares it: the account, never root where it is its
|
// The agent's module, in the shape the catalogue's declares it: the account, never root where it is its
|
||||||
// own; its directory under that home, owned by it.
|
// own; its directory under that home, owned by it.
|
||||||
const agentModule = `{"module": "agent", "version": "1", "resources": [
|
const agentModule = `{"module": "agent", "version": "1", "resources": [
|
||||||
{"id": "account", "type": "user", "name": "${machine:agent-account}", "root": "${machine:agent-root}"},
|
{"id": "account", "type": "user", "name": "${machine:agent-account}", "home": "${machine:agent-home}",
|
||||||
|
"root": "${machine:agent-root}"},
|
||||||
{"id": "home", "type": "directory", "path": "${machine:agent-home}/.agent", "mode": "0700",
|
{"id": "home", "type": "directory", "path": "${machine:agent-home}/.agent", "mode": "0700",
|
||||||
"owner": "${machine:agent-account}"}
|
"owner": "${machine:agent-account}"}
|
||||||
]}`
|
]}`
|
||||||
@@ -57,13 +58,18 @@ func TestTheAgentAccountIsDeclaredNeverRootOnlyToAnEngineThatJudgesIt(t *testing
|
|||||||
}
|
}
|
||||||
|
|
||||||
user, home := compose(Resolution{Account: "ops", AgentAccount: "agent"}, Rendering{JudgesRoot: true})
|
user, home := compose(Resolution{Account: "ops", AgentAccount: "agent"}, Rendering{JudgesRoot: true})
|
||||||
if user["name"] != "agent" || user[RootField] != RootNever {
|
if user["name"] != "agent" || user[RootField] != RootNever || user["home"] != "/home/agent" {
|
||||||
t.Errorf("an engine that judges root is sent the agent account never to become root: %v", user)
|
t.Errorf("an engine that judges root is sent the agent account never to become root: %v", user)
|
||||||
}
|
}
|
||||||
if home["path"] != "/home/agent/.agent" || home["owner"] != "agent" {
|
if home["path"] != "/home/agent/.agent" || home["owner"] != "agent" {
|
||||||
t.Errorf("the agent's directory is under its own home, its own: %v", home)
|
t.Errorf("the agent's directory is under its own home, its own: %v", home)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user, _ = compose(Resolution{Account: "ops", AgentAccount: "agent", AgentAccountHome: "/srv/agent"}, Rendering{JudgesRoot: true})
|
||||||
|
if user["home"] != "/srv/agent" {
|
||||||
|
t.Errorf("an agent account named with a home of its own is made there: %v", user)
|
||||||
|
}
|
||||||
|
|
||||||
user, _ = compose(Resolution{Account: "ops", AgentAccount: "agent"}, Rendering{})
|
user, _ = compose(Resolution{Account: "ops", AgentAccount: "agent"}, Rendering{})
|
||||||
if _, sent := user[RootField]; sent || user["name"] != "agent" {
|
if _, sent := user[RootField]; sent || user["name"] != "agent" {
|
||||||
t.Errorf("an older engine, which parses strictly, is sent root: %v", user)
|
t.Errorf("an older engine, which parses strictly, is sent root: %v", user)
|
||||||
|
|||||||
@@ -145,8 +145,10 @@ func machineInto(resource map[string]any, facts map[string]string, module string
|
|||||||
// the shell module makes the operator's account its holder's login shell, and the desktop's
|
// the shell module makes the operator's account its holder's login shell, and the desktop's
|
||||||
// watchers run as that account (novox/hq ADR 0176, ADR 0177) — neither can name the person. And a
|
// watchers run as that account (novox/hq ADR 0176, ADR 0177) — neither can name the person. And a
|
||||||
// user's `root`: the agent's module declares the account agents run as with ${machine:agent-root},
|
// user's `root`: the agent's module declares the account agents run as with ${machine:agent-root},
|
||||||
// "never" only where that account is the agents' own (novox/hq ADR 0266).
|
// "never" only where that account is the agents' own (novox/hq ADR 0266), and its `home`, so an account
|
||||||
for _, field := range []string{"path", "owner", "content", "name", "user", "root"} {
|
// the operator named with a home of its own is made there (${machine:agent-home}); the node-engine reads a
|
||||||
|
// user's home only when it creates the account, so an existing one is never moved.
|
||||||
|
for _, field := range []string{"path", "owner", "content", "name", "user", "root", "home"} {
|
||||||
s, ok := resource[field].(string)
|
s, ok := resource[field].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user