You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Neither tokio nor the std library supports this, which leaves a temporary moment where the socket is world-accessible. By default, we want the permission to be 0o600 (only owner readable and writeable) with the option to configure as 0o666 (anyone can read and write) for looser access.
The text was updated successfully, but these errors were encountered:
// Workaround for https://github.com/tokio-rs/tokio/issues/4422let socket = Socket::new(socket2::Domain::UNIX, socket2::Type::STREAM,None)?;unsafe{// Socket-level chmod is propagated to the file created by Socket::bind.// We need to chmod /before/ creating the file, because otherwise there is a brief window where// the file is world-accessible (unless restricted by the global umask).if libc::fchmod(socket.as_raw_fd(),0o600) == -1{returnErr(std::io::Error::last_os_error());}}
socket.bind(&socket2::SockAddr::unix(path)?)?;
socket.listen(1024)?;UnixListener::from_std(socket.into())
// Workaround for https://github.com/tokio-rs/tokio/issues/4422let socket = Socket::new(socket2::Domain::UNIX, socket2::Type::STREAM,None)?;unsafe{// Socket-level chmod is propagated to the file created by Socket::bind.// We need to chmod /before/ creating the file, because otherwise there is a brief window where// the file is world-accessible (unless restricted by the global umask).if libc::fchmod(socket.as_raw_fd(),0o600) == -1{returnErr(std::io::Error::last_os_error());}}
socket.bind(&socket2::SockAddr::unix(path)?)?;
socket.listen(1024)?;UnixListener::from_std(socket.into())
Just passing by through linked GitHub issues, but figured I'd mention that you'll also need to manually set the socket as non-blocking.
The caller is responsible for ensuring that the listener is in non-blocking mode. Otherwise all I/O operations on the listener will block the thread, which will cause unexpected behavior. Non-blocking mode can be set using set_nonblocking.
Tokio tracking issue: tokio-rs/tokio#4422
Example of how to do this with
libc
andsocket2
: https://github.com/stackabletech/secret-operator/pull/26/filesNeither
tokio
nor the std library supports this, which leaves a temporary moment where the socket is world-accessible. By default, we want the permission to be0o600
(only owner readable and writeable) with the option to configure as0o666
(anyone can read and write) for looser access.The text was updated successfully, but these errors were encountered: