aboutsummaryrefslogtreecommitdiffstats
path: root/src/access/policy.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-15 23:36:09 +0000
committertv <tv@krebsco.de>2026-11-15 23:36:09 +0000
commitdefe7fe994ad5b73c8b0d5bef9a51cf9f58ec3b2 (patch)
tree89a0a3c7c5d39e430976b64c869098279319b5d1 /src/access/policy.rs
parent1a9af1eb760d7191f32dec3db0522e2184d3656a (diff)
config: a strict bootstrap policy found as the document reads it
A strict `--bootstrap-policy` is refused with `--remake`, but whether it was strict went by its JSON as given, where the node reads the policy as written into the document: a strict policy given as an envelope passed, and its genesis change was refused only once the node had started. Both now read it as written (`policy::as_written`).
Diffstat (limited to 'src/access/policy.rs')
-rw-r--r--src/access/policy.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/access/policy.rs b/src/access/policy.rs
index 54e70d0..23e445d 100644
--- a/src/access/policy.rs
+++ b/src/access/policy.rs
@@ -69,13 +69,7 @@ pub(crate) fn first(
};
let value: JsonValue = serde_json::from_str(given)
.map_err(|error| format!("bootstrap-policy isn't JSON: {error}"))?;
- let mut doc = crate::document::Document::new();
- let mut write = doc.transaction();
- store::write_path(&mut write, &path(), &value)
- .map_err(|error| format!("bootstrap-policy: {error}"))?;
- let policy = of(&write);
- write.rollback();
- match policy {
+ match as_written(&value).map_err(|error| format!("bootstrap-policy: {error}"))? {
Policy::Unknown(why) => Err(format!("bootstrap-policy: one this node doesn't know: {why}")),
Policy::Open => Err("bootstrap-policy: no policy".to_owned()),
policy if policy.strict() && bootstrap_keys.is_empty() => Err(
@@ -86,6 +80,16 @@ pub(crate) fn first(
}
}
+/// The policy `value` is, written at the policy's place, as every node reads it there.
+pub(crate) fn as_written(value: &JsonValue) -> Result<Policy, String> {
+ let mut doc = crate::document::Document::new();
+ let mut write = doc.transaction();
+ store::write_path(&mut write, &path(), value).map_err(|error| error.to_string())?;
+ let policy = of(&write);
+ write.rollback();
+ Ok(policy)
+}
+
/// The policy `doc` holds, read in typed JSON: what continuum writes there reads as it
/// is, plain JSON or an envelope, and anything else (a text, a counter, bytes) as itself,
/// tagged, so that a policy holding one where it says what it is reads as one nobody