fix: set the in-agent socket's mode at bind, not afterwards
hive-c0re pushes todos into each agent over the in-agent socket, and every one of those dials has been failing with EACCES. The socket is created by todo_server::bind with no mode set at all, so it lands at 0777 & ~umask -- typically 0755. connect(2) on a unix socket requires *write* permission, and hive-core is neither the socket's owner nor in its group, so it is locked out. The tell is the sibling socket. web.sock is bound in the same directory, by the same process, as the same user, and does set its mode (0666) immediately after bind. Only the socket missing that call fails, which is also why no ownership or chown theory explained it: both sockets share every directory they live in, so anything at the directory level would have broken them together. Fix is the two lines web.sock already had. Access control for these sockets is the containing directory's job, not the socket's -- the mode here only has to not exclude the host daemon that is supposed to reach it. Observable effect: scheduled prompts and message wakes reach agents again. An agent whose wake is dropped still sees its messages whenever something else wakes it, so the failure presents as agents that look healthy but answer late, or not at all if nothing else is waking them.
This commit is contained in:
parent
5837bcc870
commit
cfe965783e
1 changed files with 15 additions and 1 deletions
|
|
@ -22,6 +22,7 @@
|
|||
//! existing best-effort JSON-line clients (they just change which socket
|
||||
//! they dial, not the payload).
|
||||
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
@ -125,6 +126,15 @@ pub async fn run(
|
|||
/// Bind a `UnixListener` at `path`, creating the parent dir and unlinking a
|
||||
/// stale socket left by a prior boot (which would otherwise block `bind`
|
||||
/// with `EADDRINUSE`).
|
||||
///
|
||||
/// The mode is set **here, at creation** — not corrected afterwards by
|
||||
/// whoever notices. `connect(2)` on a unix socket requires *write*
|
||||
/// permission, and `bind` leaves `0777 & ~umask` (typically `0755`), which
|
||||
/// silently excludes every uid but the harness's own. `hive-c0re` pushes
|
||||
/// todos in over this socket from the host, so that default locks it out.
|
||||
/// Same two lines the sibling `web.sock` has carried all along
|
||||
/// (`web_ui::serve`); access control is the containing directory's job, not
|
||||
/// the socket's.
|
||||
fn bind(path: &Path) -> Result<UnixListener> {
|
||||
if let Some(parent) = path.parent() {
|
||||
std::fs::create_dir_all(parent)
|
||||
|
|
@ -133,7 +143,11 @@ fn bind(path: &Path) -> Result<UnixListener> {
|
|||
if path.exists() {
|
||||
let _ = std::fs::remove_file(path);
|
||||
}
|
||||
UnixListener::bind(path).with_context(|| format!("bind in-agent socket {}", path.display()))
|
||||
let listener = UnixListener::bind(path)
|
||||
.with_context(|| format!("bind in-agent socket {}", path.display()))?;
|
||||
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o666))
|
||||
.with_context(|| format!("set perms on in-agent socket {}", path.display()))?;
|
||||
Ok(listener)
|
||||
}
|
||||
|
||||
/// Handle one connection: read a single JSON request line, apply it to the
|
||||
|
|
|
|||
Loading…
Reference in a new issue