From: Andre Noll Date: Mon, 12 Jan 2015 00:07:19 +0000 (+0100) Subject: Abstract sockets for server and audiod. X-Git-Tag: v0.5.5~60^2~1 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=fdbdd1fd575d7d37d4fb182252107a4d3816853c;hp=fdbdd1fd575d7d37d4fb182252107a4d3816853c Abstract sockets for server and audiod. 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. ---