]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Abstract sockets for server and audiod.
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 12 Jan 2015 00:07:19 +0000 (01:07 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Sat, 14 Feb 2015 10:45:26 +0000 (11:45 +0100)
Currently para_server and para_audiod won't start if the socket
specials can not be created, for example because /var/paraslash does
not exist or has insufficient permissions.

The abstract namespace feature for local sockets allows to go
without socket specials, as implemented in this commit. The feature
is a non-portable Linux extension though, so a fallback to pathname
sockets is necessary for other operating systems and for backward
compatibility.

For para_server the situation is simple because the socket is created
by the afs process, and only command handlers are supposed to connect.
Since afs and the command handlers are part of the same executable
(para_server), there are no compatibility issues. Hence we simply
use an abstract socket on Linux and a pathname socket elsewhere.

For para_audiod things are more complicated because two executables
are involved: para_audioc and para_audiod. To allow older versions
of para_audioc to connect to recent versions of para_audiod, we let
audiod listen on one socket of either type. Startup fails only if
neither socket can be created.

As for the implementation, we make use of the fact that it makes
not much sense to call create_local_socket() with permission mode
equal to 0, and that there are no permission modes for abstract
sockets. With the patch applied, specifying the mode as zero instructs
create_local_socket() to create an abstract socket. In this case we
also use the given pathname but prepend a zero byte at the front of
the ->sun_path member of struct sockaddr_un to bind(2) the socket to
an address in the abstract namespace.

On the client side (connect_local_socket()) we first try to connect to
an abstract address and fall back to pathnames sockets on errors. This
change is transparent to the callers of connect_local_socket. Hence
para_audioc and afs command handlers need no modifications at all.

The patch also adds a section on abstract sockets to the user manual.


No differences found