Fix for unix sockets after addition of port ACLs (#5184)
* Fixes #5181 * Add all ACLs to unix sockets
Chris Akritidis committed
Jan 16, 2019 at 16:05 UTC
9c4f5fbb3e44ff6ec45d77d160464f67db322958
1 file changed
+11
-15
libnetdata/socket/socket.c
+11
-15
@@ -328,7 +328,6 @@ static inline int bind_to_this(LISTEN_SOCKETS *sockets, const char *definition,
328
329
int protocol = IPPROTO_TCP, socktype = SOCK_STREAM;
330
const char *protocol_str = "tcp";
331
- int unix_socket=0;
331
332
if(strncmp(ip, "tcp:", 4) == 0) {
333
ip += 4;
@@ -343,10 +342,19 @@ static inline int bind_to_this(LISTEN_SOCKETS *sockets, const char *definition,
342
protocol_str = "udp";
343
}
344
else if(strncmp(ip, "unix:", 5) == 0) {
346
- ip += 5;
345
+ char *path = ip + 5;
346
socktype = SOCK_STREAM;
347
protocol_str = "unix";
349
- unix_socket=1;
348
+ int fd = create_listen_socket_unix(path, listen_backlog);
349
+ if (fd == -1) {
350
+ error("LISTENER: Cannot create unix socket '%s'", path);
351
+ sockets->failed++;
352
+ } else {
353
+ acl_flags = WEB_CLIENT_ACL_DASHBOARD | WEB_CLIENT_ACL_REGISTRY | WEB_CLIENT_ACL_BADGE | WEB_CLIENT_ACL_MGMT | WEB_CLIENT_ACL_NETDATACONF | WEB_CLIENT_ACL_STREAMING;
354
+ listen_sockets_add(sockets, fd, AF_UNIX, socktype, protocol_str, path, 0, acl_flags);
355
+ added++;
356
+ }
357
+ return added;
358
}
359
360
char *e = ip;
@@ -394,18 +402,6 @@ static inline int bind_to_this(LISTEN_SOCKETS *sockets, const char *definition,
402
acl_flags = WEB_CLIENT_ACL_DASHBOARD | WEB_CLIENT_ACL_REGISTRY | WEB_CLIENT_ACL_BADGE | WEB_CLIENT_ACL_MGMT | WEB_CLIENT_ACL_NETDATACONF | WEB_CLIENT_ACL_STREAMING;
403
}
404
397
- if (unix_socket) {
398
- int fd = create_listen_socket_unix(port, listen_backlog);
399
- if (fd == -1) {
400
- error("LISTENER: Cannot create unix socket '%s'", port);
401
- sockets->failed++;
402
- } else {
403
- listen_sockets_add(sockets, fd, AF_UNIX, socktype, protocol_str, port, 0, acl_flags);
404
- added++;
405
- }
406
- return added;
407
- }
408
-
405
uint32_t scope_id = 0;
406
if(*interface) {
407
scope_id = if_nametoindex(interface);