fix(#2391): drop "." entirely from credential/snapshot name charset
Per mara: "i would have even disallowed ., we are making up the rules here lets go strict". validate_credential_name now restricts to [A-Za-z0-9_-] (no dot at all) instead of [A-Za-z0-9_.-] + a separate ".." substring check — simpler rule, and there's no legitimate need for a dot in either a systemd credential id or a hive- prefixed snapshot label. Matching hivectl client-side check + wire-proto doc comments updated.
This commit is contained in:
parent
720ac81235
commit
2c079afd65
3 changed files with 25 additions and 22 deletions
|
|
@ -1740,10 +1740,11 @@ async fn subvol_upgrade(socket: &Path, name: &str, yes: bool) -> Result<()> {
|
|||
/// `subvol snapshot create <agent> --label <label>` — create a read-only
|
||||
/// btrfs snapshot of an agent's state subvolume. Unlike `upgrade`, this does
|
||||
/// NOT stop the agent: btrfs snapshots are atomic + consistent to take
|
||||
/// against a live subvolume. `label` is mandatory and must start with
|
||||
/// `hive-` — hive-priv enforces the same prefix as an allow-list, so this
|
||||
/// check is belt-and-suspenders (fail fast client-side with a clear
|
||||
/// message).
|
||||
/// against a live subvolume. `label` is mandatory, must start with
|
||||
/// `hive-`, and is otherwise restricted to `[A-Za-z0-9_-]` (no `.` at all
|
||||
/// — mara: "we are making up the rules here, lets go strict"). hive-priv
|
||||
/// enforces the same rules server-side, so this check is
|
||||
/// belt-and-suspenders (fail fast client-side with a clear message).
|
||||
async fn subvol_snapshot_create(name: &str, label: String) -> Result<()> {
|
||||
if !agent_exists(name)? {
|
||||
bail!("no agent named {name:?} (no state dir under the agents root)");
|
||||
|
|
@ -1751,8 +1752,13 @@ async fn subvol_snapshot_create(name: &str, label: String) -> Result<()> {
|
|||
if !label.starts_with("hive-") {
|
||||
bail!("snapshot label {label:?} must start with \"hive-\"");
|
||||
}
|
||||
if label.contains("..") {
|
||||
bail!("snapshot label {label:?} must not contain \"..\"");
|
||||
if !label
|
||||
.bytes()
|
||||
.all(|b| b.is_ascii_alphanumeric() || matches!(b, b'_' | b'-'))
|
||||
{
|
||||
bail!(
|
||||
"snapshot label {label:?} must be [A-Za-z0-9_-] only (no \".\" — hive-priv rejects it)"
|
||||
);
|
||||
}
|
||||
let path = hive_c0re::priv_client::snapshot_agent_subvolume(name, &label)
|
||||
.await
|
||||
|
|
|
|||
Loading…
Reference in a new issue