From 9e8b1e1d13cd9c382769014d43d6f2604b396968 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Fri, 14 Apr 2017 15:36:53 +0200 Subject: [PATCH] allow abstract unix sockets MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit unix sockets named "unix:@something" are now treated as abstract sockets. Change-Id: Ieb2bb9dd1c7b420b9e3fae81590ef49c32f63802 Signed-off-by: José Bollo --- src/afb-api-ws.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/afb-api-ws.c b/src/afb-api-ws.c index 56682ddc..ba9a18a9 100644 --- a/src/afb-api-ws.c +++ b/src/afb-api-ws.c @@ -281,7 +281,7 @@ static int api_ws_socket_unix(const char *path, int server) return -1; } - if (server) + if (server && path[0] != '@') unlink(path); fd = socket(AF_UNIX, SOCK_STREAM, 0); @@ -291,6 +291,8 @@ static int api_ws_socket_unix(const char *path, int server) memset(&addr, 0, sizeof addr); addr.sun_family = AF_UNIX; strcpy(addr.sun_path, path); + if (addr.sun_path[0] == '@') + addr.sun_path[0] = 0; /* implement abstract sockets */ if (server) { rc = bind(fd, (struct sockaddr *) &addr, (socklen_t)(sizeof addr)); } else { -- 2.16.6