summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-04-14 15:36:53 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-04-14 15:36:53 +0200
commit9e8b1e1d13cd9c382769014d43d6f2604b396968 (patch)
treefed14392b710e25ec232f4d6640d53afcb93c191
parent01534912a8e32468b62d848ec1fe23004df1dd19 (diff)
allow abstract unix sockets
unix sockets named "unix:@something" are now treated as abstract sockets. Change-Id: Ieb2bb9dd1c7b420b9e3fae81590ef49c32f63802 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-api-ws.c4
1 files changed, 3 insertions, 1 deletions
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 {