JFLib

plat/control_ipc_linux.rs (Linux)#

Source: lib/plat/control_ipc_linux.rs

Nonblocking Unix sockets restricted to the effective user. Linux raw syscalls.
New code; socket paths never accept external directory or filename input.
  • struct Listener Private local listener. Dropping it closes and removes only its own socket path.

  • struct Stream One nonblocking authenticated local connection.

impl Listener

  • fn bind(app: &str) -> Result<Self, i32> Bind below a verified, non-symlink, mode-0700 directory owned by the effective UID.
  • fn endpoint(&self) -> &str Address to advertise only while control is active.
  • fn accept(&mut self) -> Result<Option<Stream>, i32> Accept at most one available connection and validate its effective UID via SO_PEERCRED.

impl Stream

  • fn read(&mut self, bytes: &mut [u8]) -> Result<Option<usize>, i32> Read available bytes. None means would block; Some(0) means peer EOF.
  • fn write(&mut self, bytes: &[u8]) -> Result<Option<usize>, i32> Write available bytes without SIGPIPE. None means would block.

Source: docs/API.md in the JFLib repository.