Support abstract Unix sockets

Allows to specify abstract Unix sockets addresses.
These Unix sockets are supported on Linux and allows to not
have file system names.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Kevin Pouget <kpouget@redhat.com>
This commit is contained in:
Frediano Ziglio 2017-09-15 18:21:32 +01:00
parent a6ccd2a309
commit 1bf9d22cf2

View File

@ -2588,8 +2588,12 @@ static int reds_init_socket(const char *addr, int portnr, int family)
local.sun_family = AF_UNIX;
g_strlcpy(local.sun_path, addr, sizeof(local.sun_path));
unlink(local.sun_path);
len = SUN_LEN(&local);
if (local.sun_path[0] == '@') {
local.sun_path[0] = 0;
} else {
unlink(local.sun_path);
}
if (bind(slisten, (struct sockaddr *)&local, len) == -1) {
perror("bind");
socket_close(slisten);