admit: give an agent her own uid through one writer
souveraine-admit creates or adopts one account via systemd-sysusers, writes the root-owned mapping health reads, and reports what NSS says afterwards instead of what it asked for. An account belongs to one agent: handing annie's to souvie is refused in both directions, as is adopting a uid >=1000. Binding is by SeedID, not the UUID filename — a mismatch is identity-drift.
This commit is contained in:
parent
14298e73f8
commit
0f8fe22ab6
10 changed files with 745 additions and 170 deletions
|
|
@ -99,25 +99,8 @@ impl AgentPrincipalConfig {
|
|||
let account = self
|
||||
.account
|
||||
.as_deref()
|
||||
.filter(|value| !value.is_empty())
|
||||
.ok_or_else(|| anyhow::anyhow!("dedicated principal requires an account"))?;
|
||||
let valid = account.len() <= 31
|
||||
&& account
|
||||
.bytes()
|
||||
.enumerate()
|
||||
.all(|(index, byte)| match (index, byte) {
|
||||
(0, b'a'..=b'z' | b'_') => true,
|
||||
(_, b'a'..=b'z' | b'0'..=b'9' | b'_' | b'-') => true,
|
||||
_ => false,
|
||||
});
|
||||
if !valid {
|
||||
anyhow::bail!(
|
||||
"invalid dedicated account `{account}`; use a lowercase Unix account name"
|
||||
);
|
||||
}
|
||||
if matches!(account, "root" | "souveraine" | "souveraine-session") {
|
||||
anyhow::bail!("account `{account}` is reserved and cannot be an agent principal");
|
||||
}
|
||||
crate::core::principal_map::validate_account_name(account)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Reference in a new issue