priv: reject double-quotes in nspawn flag entries
This commit is contained in:
parent
aa7f8e5553
commit
a922376778
1 changed files with 10 additions and 6 deletions
|
|
@ -352,13 +352,17 @@ fn agent_flake_ref(name: &str) -> String {
|
||||||
format!("{META_DIR}#{name}")
|
format!("{META_DIR}#{name}")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validate one nspawn flag entry: must be non-empty and contain no
|
/// Validate one nspawn flag entry. Must be non-empty and contain no
|
||||||
/// ASCII whitespace or null bytes. Whitespace would split the entry
|
/// ASCII whitespace (would split the entry when the start script
|
||||||
/// into multiple flags when the start script expands
|
/// expands `$EXTRA_NSPAWN_FLAGS` unquoted), double-quotes (would
|
||||||
/// `$EXTRA_NSPAWN_FLAGS` unquoted.
|
/// break the `EXTRA_NSPAWN_FLAGS="..."` conf line), or null bytes.
|
||||||
fn validate_nspawn_flag(flag: &str) -> Result<()> {
|
fn validate_nspawn_flag(flag: &str) -> Result<()> {
|
||||||
if flag.is_empty() || flag.bytes().any(|b| b == 0 || b.is_ascii_whitespace()) {
|
if flag.is_empty()
|
||||||
bail!("invalid nspawn flag {flag:?}: must be non-empty and contain no whitespace or null bytes");
|
|| flag.bytes().any(|b| b == 0 || b == b'"' || b.is_ascii_whitespace())
|
||||||
|
{
|
||||||
|
bail!(
|
||||||
|
"invalid nspawn flag {flag:?}: must be non-empty and contain no whitespace, double-quotes, or null bytes"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue