[edge] Share fixes: per-network password limit and no eviction, revocation epoch never goes down, stray share tokens stripped on every host, admin socket bound in a private directory
This commit is contained in:
@@ -269,9 +269,21 @@ fn bind(path: &Path) -> std::io::Result<tokio::net::UnixListener> {
|
||||
));
|
||||
}
|
||||
}
|
||||
let l = tokio::net::UnixListener::bind(path)?;
|
||||
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o660))?;
|
||||
Ok(l)
|
||||
// Bind inside a fresh 0700 directory, set the mode, then move the socket into place, so
|
||||
// there is no moment in which the socket exists with the process umask's permissions.
|
||||
use std::os::unix::fs::DirBuilderExt;
|
||||
let parent = path.parent().unwrap_or(Path::new("."));
|
||||
let private = parent.join(format!(".ianitor-admin-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&private);
|
||||
std::fs::DirBuilder::new().mode(0o700).create(&private)?;
|
||||
let staged = private.join("admin.sock");
|
||||
let bound = tokio::net::UnixListener::bind(&staged).and_then(|l| {
|
||||
std::fs::set_permissions(&staged, std::fs::Permissions::from_mode(0o660))?;
|
||||
std::fs::rename(&staged, path)?;
|
||||
Ok(l)
|
||||
});
|
||||
let _ = std::fs::remove_dir_all(&private);
|
||||
bound
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
||||
Reference in New Issue
Block a user