summaryrefslogtreecommitdiffstats
path: root/src/swarm
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-27 00:58:45 +0100
committertv <tv@krebsco.de>2026-10-27 00:58:45 +0100
commitb90cfd1fde4e1c00d03e44976753d0044b273bda (patch)
tree23c401e56b3caf6644c07091563e73827b43e177 /src/swarm
parentfde8a76ec5d8e697d9b13470cd15ed324bae3d00 (diff)
introduce node keys
Diffstat (limited to 'src/swarm')
-rw-r--r--src/swarm/auth.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/swarm/auth.rs b/src/swarm/auth.rs
index 3bfbd4d..088f615 100644
--- a/src/swarm/auth.rs
+++ b/src/swarm/auth.rs
@@ -40,9 +40,9 @@ struct Rejections {
suppressed: u64,
}
-/// The key is a secret: a file others may read is worth a warning (not an error: a
-/// group may be deliberate, e.g. shared with a deployment tool).
-fn warn_if_readable_by_others(path: &Path) {
+/// A key is a secret: a file others may read is worth a warning (not an error: a
+/// group may be deliberate, e.g. shared with a deployment tool). `what`: which key.
+pub(crate) fn warn_if_readable_by_others(path: &Path, what: &str) {
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
@@ -52,13 +52,13 @@ fn warn_if_readable_by_others(path: &Path) {
tracing::warn!(
path = %path.display(),
mode = format!("{:o}", mode & 0o777),
- "The swarm key file is readable by others than its owner; chmod 600 it"
+ "The {what} file is readable by others than its owner; chmod 600 it"
);
}
}
}
#[cfg(not(unix))]
- let _ = path;
+ let _ = (path, what);
}
/// At most one rejection log line per this interval.
@@ -70,7 +70,7 @@ impl SwarmKey {
pub(crate) fn from_file(path: &Path) -> Result<Self> {
let key = std::fs::read(path)
.with_context(|| format!("Reading the swarm key from {}", path.display()))?;
- warn_if_readable_by_others(path);
+ warn_if_readable_by_others(path, "swarm key");
if key.len() < 16 {
bail!(
"The swarm key in {} has {} bytes; use at least 16 (32 random bytes recommended)",