agent ssh unit on every agent with a store, one ssh_config, controller reads the ca key
This commit is contained in:
parent
910f9a6f50
commit
624d5f24f8
1 changed files with 99 additions and 165 deletions
|
|
@ -2879,28 +2879,46 @@ let
|
|||
&& lib.length roleWriters == 1;
|
||||
}
|
||||
{
|
||||
# The agents' `update` on the sign path comes from the shared agent
|
||||
# policy (swarm-secret-client), not from a unit here. Of the policies
|
||||
# these units write, only the granter's names the mount: the controller,
|
||||
# which writes the shared one, holds nothing on it.
|
||||
name = "of the policies the host writes, only the granter's has a grant on the agent SSH mount";
|
||||
# The agents' `update` on the sign path is the `hive-agent-ssh` policy
|
||||
# (swarm-secret-client), written by the controller at run time, not a unit
|
||||
# here. Of the policies these units write, the granter's makes the mount,
|
||||
# and the controller's only reads the CA's public key: it cannot sign,
|
||||
# write the role or reach any other path on the mount.
|
||||
name = "of the policies the host writes, only the granter's writes the agent SSH mount and the controller's only reads its CA";
|
||||
ok =
|
||||
let
|
||||
cg = grantsIn baoGrantHere.systemd.services.swarm-bao-controller-policy.script;
|
||||
onMount = lib.filter (g: lib.hasPrefix "ssh-agents" g.path);
|
||||
in
|
||||
onMount cg == [ ]
|
||||
onMount cg == [
|
||||
{
|
||||
path = "ssh-agents/config/ca";
|
||||
caps = [ "read" ];
|
||||
}
|
||||
]
|
||||
&& lib.all (p: grantFor cg p == null) [
|
||||
"ssh-agents/sign/swarm-agent"
|
||||
"ssh-agents/roles/swarm-agent"
|
||||
"ssh-agents/config/ca/x"
|
||||
"sys/mounts/ssh-agents"
|
||||
]
|
||||
# The control: the granter's grants do name the mount.
|
||||
&& onMount granterGrants != [ ]
|
||||
&& lib.all (u: onMount (grantsIn baoGrantHere.systemd.services.${u}.script) == [ ]) (
|
||||
lib.filter (u: u != "swarm-bao-agent-ssh-policy") grantingUnitNames
|
||||
lib.filter (
|
||||
u:
|
||||
!(lib.elem u [
|
||||
"swarm-bao-agent-ssh-policy"
|
||||
"swarm-bao-controller-policy"
|
||||
])
|
||||
) grantingUnitNames
|
||||
);
|
||||
}
|
||||
{
|
||||
# The shared agent policy (swarm-secret-client) names the mount and the
|
||||
# The SSH signing policy (swarm-secret-client) names the mount and the
|
||||
# role; the unit above and the agent module spell the same two strings
|
||||
# from ../host-modules/lib/ssh-agent-ca.nix.
|
||||
name = "the SSH mount and role the shared agent policy names are the ones the swarm writes";
|
||||
name = "the SSH mount and role the signing policy names are the ones the swarm writes";
|
||||
ok =
|
||||
let
|
||||
ca = import ../host-modules/lib/ssh-agent-ca.nix { };
|
||||
|
|
@ -2908,6 +2926,7 @@ let
|
|||
in
|
||||
lib.hasInfix ''pub const SSH_MOUNT: &str = "${ca.mountPath}";'' policy
|
||||
&& lib.hasInfix ''pub const SSH_ROLE: &str = "${ca.roleName}";'' policy
|
||||
&& lib.hasInfix ''pub const SSH_POLICY: &str = "hive-agent-ssh";'' policy
|
||||
&& lib.hasInfix "bao write ssh-agents/roles/${ca.roleName} -" baoGrantHere.systemd.services.swarm-bao-agent-ssh-policy.script;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue