scope the cache access to hive-core: client-side nix copy, daemon trusts only the key
This commit is contained in:
parent
ecd4445680
commit
dab7768869
1 changed files with 365 additions and 271 deletions
|
|
@ -881,18 +881,32 @@ let
|
|||
# The daemon only learns the cache from the fragment the root unit
|
||||
# writes, and lists as trusted the one address from the host's
|
||||
# configuration. A host with no unit has no include.
|
||||
name = "the host's nix.conf includes the cache fragment the root unit writes, with the cache's address";
|
||||
name = "the host's nix.conf includes a fragment that trusts only the swarm key, and only hive-core gets the token";
|
||||
ok =
|
||||
let
|
||||
u = units.hive-priv-cache-facts;
|
||||
c0re = allLocal.systemd.services.hive-c0re.environment;
|
||||
in
|
||||
lib.hasInfix "!include /run/hyperhive-nix/cache.conf" allLocal.nix.extraOptions
|
||||
&& !(lib.hasInfix "hyperhive-nix" noIdentity.nix.extraOptions)
|
||||
&& lib.hasInfix "conf=/run/hyperhive-nix/cache.conf" u.script
|
||||
&& lib.hasInfix "extra-trusted-substituters = https://attic.t.local/swarm" u.script
|
||||
&& lib.hasInfix ''fragment="extra-trusted-public-keys = $key"'' u.script
|
||||
&& lib.hasInfix ''atomic_write_secret 0644 "" "$conf"'' u.script
|
||||
# The daemon is told no substituter and no netrc: no other client of it
|
||||
# can fetch from the cache or send the token.
|
||||
&& !(lib.hasInfix "extra-trusted-substituters" u.script)
|
||||
&& !(lib.hasInfix "trusted-substituters" allLocal.nix.extraOptions)
|
||||
&& !(lib.hasInfix "netrc-file" u.script)
|
||||
# The token's one unprivileged reader is the hive-core group.
|
||||
&& lib.hasInfix "client_netrc=/run/hyperhive-nix/netrc" u.script
|
||||
&& lib.hasInfix ''atomic_write_secret 0640 ":hive-core" "$client_netrc"'' u.script
|
||||
&& lib.elem "d /run/hyperhive-nix 0755 root root - -" allLocal.systemd.tmpfiles.rules
|
||||
# Control for the absence: the lookup finds the unit's other variable.
|
||||
# hive-c0re is told the address; hive-priv no longer is.
|
||||
&& c0re.HIVE_C0RE_CACHE_URL == "https://attic.t.local/swarm"
|
||||
&& !(noIdentity.systemd.services.hive-c0re.environment ? HIVE_C0RE_CACHE_URL)
|
||||
# Control for the absences: the lookups find the units' other variables.
|
||||
&& c0re ? HOME
|
||||
&& noIdentity.systemd.services.hive-c0re.environment ? HOME
|
||||
&& allLocal.systemd.services.hive-priv.environment ? NIX_REMOTE
|
||||
&& !(allLocal.systemd.services.hive-priv.environment ? HIVE_PRIV_CACHE_URL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue