Description
When creating a session with atch start, the socket file is momentarily created with S_IXUSR set (mode 0755), then corrected to 0600 via chmod. During this window, atch list reads the stale permission and shows the session as [attached].
Reproduction
atch start session1
- Immediately run
atch list → session1 may show [attached] despite no client being connected
Root cause
In create_socket(), umask(077) is set before socket() but restored before bind(). With the default shell umask (022), bind() creates the socket file with mode 0755 (S_IXUSR present). The subsequent chmod(name, 0600) fixes it, but there's a TOCTOU window.
Suggested fix
Use umask(0177) before bind() so the socket is created directly with mode 0600 (no S_IXUSR). Restore umask after bind.
Description
When creating a session with
atch start, the socket file is momentarily created withS_IXUSRset (mode 0755), then corrected to 0600 viachmod. During this window,atch listreads the stale permission and shows the session as[attached].Reproduction
atch start session1atch list→ session1 may show[attached]despite no client being connectedRoot cause
In
create_socket(),umask(077)is set beforesocket()but restored beforebind(). With the default shell umask (022),bind()creates the socket file with mode 0755 (S_IXUSR present). The subsequentchmod(name, 0600)fixes it, but there's a TOCTOU window.Suggested fix
Use
umask(0177)beforebind()so the socket is created directly with mode 0600 (no S_IXUSR). Restore umask after bind.