aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/bootstrap.rs
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/swarm/bootstrap.rs
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/swarm/bootstrap.rs')
-rw-r--r--src/swarm/bootstrap.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/swarm/bootstrap.rs b/src/swarm/bootstrap.rs
index 5c3b5ef..aa6d06b 100644
--- a/src/swarm/bootstrap.rs
+++ b/src/swarm/bootstrap.rs
@@ -110,11 +110,16 @@ pub(crate) async fn bootstrap(state: &AppState, seeds: &[String], start: Start)
(crate::access::registry::user_path(name), entry)
})
.collect();
+ // Its policy too: no change of the swarm is then from before it.
+ let policy = state.first_policy.clone();
state
.mutate_doc(move |doc| {
for (path, entry) in &users {
store::write_path(doc, path, entry)?;
}
+ if let Some(policy) = &policy {
+ store::write_path(doc, &crate::access::policy::path(), policy)?;
+ }
store::write_path(doc, &swarm_id_path(), &recorded)?;
store::write_path(
doc,
@@ -130,7 +135,7 @@ pub(crate) async fn bootstrap(state: &AppState, seeds: &[String], start: Start)
})
.await
.context(
- "Recording the swarm ID, its neighbours, its topology and dissemination, its first users",
+ "Recording the swarm ID, its neighbours, its topology and dissemination, its first users and policy",
)?;
if let Some(root) = crate::swarm::roots::own(state).await {
info!(root = %root, "The swarm's root: a node joining may be given it (--genesis-root), to take no other");