Trait ListenerOptionsExt

Source
pub trait ListenerOptionsExt: Sized + Sealed {
    // Required method
    fn mode(self, mode: mode_t) -> Self;
}
Available on Unix only.
Expand description

Unix-specific listener options.

Required Methods§

Source

fn mode(self, mode: mode_t) -> Self

Sets the file mode (Unix permissions) to be applied to the socket file.

Not all Unix systems respect this mode when checking permissions in connect()! Linux is known to perform full permission checks for all directories along the path to the socket file in addition to checking permissions on the socket file itself, while FreeBSD only checks directories but not the socket file itself. If you expect your program to be used on a wide range of Unix systems, do not rely on this as a security mechanism.

§Implementation notes

An opportunistic fchmod() is performed on the socket. If the system responds with a EINVAL, Interprocess concludes that fchmod() on sockets is not supported on the platform, remembers this fact in an atomic global variable and falls back to a temporary umask change.

Linux is known to support fchmod() on Unix domain sockets, while FreeBSD is known not to.

Note that the fallback behavior inherently racy: if you specify this mode as, say, 666₈ and have another thread create a file during the critical section between the first umask() call and the one performed just before returning from .create_*(), that file will have mode 666₈. There is nothing Interprocess can do about this, as POSIX prescribes the umask to be shared across threads.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§