aboutsummaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
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),