agents: login shells read the hive facts too; test the readers
Part of #5081. Follow-up to the review of #5131. - Before this PR, claude read CLAUDE_REMOTE_CONTROL_SESSION_NAME_PREFIX from managed-settings.json in every context. The environment generator reaches every unit of the container's manager, including `machinectl shell` (hivectl choom): machined starts it as a transient container-shell@ unit (systemd 260.5 src/machine/machine.c:980-1004), and every unit's exec environment starts from the manager environment the generators fill (src/core/unit.c:5557, src/core/manager.c:3990-4001). Shells no unit starts do not get it: `nixos-container root-login` / `run` enter with nsenter + `su -l`, and getty logins go through login(1). So hive-facts.nix now also exports the generator's output from /etc/set-environment (environment.extraInit). - The generator's read loop kept a last line only when it ended in a newline; it now keeps one without. - checks.script-test-agent-hive-facts runs the rendered generator and the shell snippet (under dash and bash's sh) against sample files: both facts, a planted LD_PRELOAD/PATH line, a last line without a newline, an empty file and no file. - identity.rs: hive_name()'s doc names the facts file as the source.
This commit is contained in:
parent
c87a4d2c1a
commit
c8df666bf3
6 changed files with 172 additions and 28 deletions
|
|
@ -31,9 +31,9 @@ pub fn hive_domain() -> Option<String> {
|
|||
/// Human display name of this hive (e.g. `pr1ma`). Distinct from
|
||||
/// [`hive_domain`] — the domain is the machine-readable DNS address;
|
||||
/// this is the prose label humans use in conversation. Returns None
|
||||
/// when the host-side `services.hyperhive.hiveName` option is unset,
|
||||
/// in which case callers fall back to the domain or the short label
|
||||
/// at their discretion.
|
||||
/// when `/etc/hyperhive-hive-facts` carries no name (the host's
|
||||
/// `services.hyperhive.hiveName` is unset), in which case callers fall
|
||||
/// back to the domain or the short label at their discretion.
|
||||
#[must_use]
|
||||
pub fn hive_name() -> Option<String> {
|
||||
non_empty_env("HYPERHIVE_HIVE_NAME")
|
||||
|
|
|
|||
Loading…
Reference in a new issue