aboutsummaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-15 16:43:53 +0000
committertv <tv@krebsco.de>2026-11-15 16:43:53 +0000
commitaf120b87c42ca56f69bbe6f8d27c023919742430 (patch)
tree60b493edf48aad388ddc9682498f1ad8c5527b53 /src/config
parent2d1c64a6e7134f4d6942d4539b27d45f14e7538c (diff)
swarm: a new swarm's policy recorded in its genesis change
A swarm strict from its start had its policy written by its first user in a later change. A change is judged by the policy at its history, so any member could always add a change whose history is from before the policy: judged by none, needing no signature, taken whenever it comes. Since signed values are read by `seq`, an envelope planted there with the highest `seq` there is can never be followed: a ban, a user, a declaration, for good. `--bootstrap-policy JSON`, with `--genesis`, records the policy in the genesis change, with the first users: then no change of the swarm is from before it. It must be a policy this node knows, and a strict one needs `--bootstrap-keys`, or nobody could sign what decides who may do what.
Diffstat (limited to 'src/config')
-rw-r--r--src/config/mod.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs
index c0abc09..1686792 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -180,6 +180,13 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[
"With bootstrap-users: their SSH keys, as authorized_keys lines (ssh-ed25519 <base64> [comment], named by the comment), recorded in their entries: to log in by key and sign values (docs/access.md), so a swarm can be strict from its start.",
),
option(
+ "bootstrap-policy",
+ Kind::Text,
+ "JSON",
+ None,
+ "With genesis: the swarm's write protection policy (docs/access.md), recorded in its first change with its first users, so that no change of the swarm is from before it: {\"version\": 1, \"values\": \"signed\"} makes it strict from its start, and needs bootstrap-keys.",
+ ),
+ option(
"refused-writes-per-minute",
Kind::Integer,
"COUNT",
@@ -622,6 +629,7 @@ pub(crate) struct Settings {
pub(crate) bootstrap_users: Vec<String>,
#[serde(default)]
pub(crate) bootstrap_keys: Vec<String>,
+ pub(crate) bootstrap_policy: Option<String>,
pub(crate) genesis_root: Option<String>,
#[serde(default)]
pub(crate) strict_keys: Vec<String>,
@@ -898,6 +906,11 @@ impl Settings {
"bootstrap-users names the first users of a new swarm; it needs genesis (drop it once the swarm exists)"
);
}
+ if self.bootstrap_policy.is_some() && !self.genesis {
+ bail!(
+ "bootstrap-policy is the policy of a new swarm; it needs genesis (drop it once the swarm exists)"
+ );
+ }
if let Some(bad) = self
.bootstrap_users
.iter()
@@ -910,6 +923,11 @@ impl Settings {
{
bail!("{why}");
}
+ if let Err(why) =
+ crate::access::policy::first(self.bootstrap_policy.as_deref(), &self.bootstrap_keys)
+ {
+ bail!("{why}");
+ }
if let Some(root) = &self.genesis_root
&& crate::swarm::roots::parse(root).is_none()
{
@@ -1075,6 +1093,7 @@ impl Settings {
("protocol-writers", !self.protocol_writers.is_empty()),
("bootstrap-users", !self.bootstrap_users.is_empty()),
("bootstrap-keys", !self.bootstrap_keys.is_empty()),
+ ("bootstrap-policy", self.bootstrap_policy.is_some()),
("alias", self.alias.is_some()),
("dashboard-url", self.dashboard_url.is_some()),
("debug-api", self.debug_api),