Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support abstract namespaces with UNIX sockets #1933

Open
herwinw opened this issue Mar 25, 2024 · 0 comments
Open

Support abstract namespaces with UNIX sockets #1933

herwinw opened this issue Mar 25, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@herwinw
Copy link
Member

herwinw commented Mar 25, 2024

Another one for the long list of things I want to do: abstract namespaces for UNIX sockets.

A selective copy-paste from https://www.man7.org/linux/man-pages/man7/unix.7.html:

an abstract socket address is distinguished (from a
pathname socket) by the fact that sun_path[0] is a null
byte ('\0'). The socket's address in this namespace is
given by the additional bytes in sun_path that are covered
by the specified length of the address structure. (Null
bytes in the name have no special significance.) The name
has no connection with filesystem pathnames. When the
address of an abstract socket is returned, the returned
addrlen is greater than sizeof(sa_family_t) (i.e., greater
than 2), and the name of the socket is contained in the
first (addrlen - sizeof(sa_family_t)) bytes of sun_path.

A simple example in Ruby:

require 'socket'

path = "\x00abstract"
server = UNIXServer.new(path)
client = UNIXSocket.new(path)
client.write("Hello")
socket = server.accept
puts socket.recvfrom(5).first
socket.close
client.close
server.close

I completely skipped this for now to get the specs passing, but we should support this too. And preferably write some specs for them as well.

@herwinw herwinw added the enhancement New feature or request label Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant