diff options
author | Chris Akritidis <43294513+cakrit@users.noreply.github.com> | 2019-01-16 16:05:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-16 16:05:41 +0100 |
commit | 9c4f5fbb3e44ff6ec45d77d160464f67db322958 (patch) | |
tree | e452bdab5307d3b0be6cf775600ab08f78f092f1 /libnetdata/socket | |
parent | 0dbd4fb0cba640347d8fd88fec6071a5510828e5 (diff) |
Fix for unix sockets after addition of port ACLs (#5184)
* Fixes #5181
* Add all ACLs to unix sockets
Diffstat (limited to 'libnetdata/socket')
-rw-r--r-- | libnetdata/socket/socket.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/libnetdata/socket/socket.c b/libnetdata/socket/socket.c index a4574f4dd1..037e680bd3 100644 --- a/libnetdata/socket/socket.c +++ b/libnetdata/socket/socket.c @@ -328,7 +328,6 @@ static inline int bind_to_this(LISTEN_SOCKETS *sockets, const char *definition, int protocol = IPPROTO_TCP, socktype = SOCK_STREAM; const char *protocol_str = "tcp"; - int unix_socket=0; if(strncmp(ip, "tcp:", 4) == 0) { ip += 4; @@ -343,10 +342,19 @@ static inline int bind_to_this(LISTEN_SOCKETS *sockets, const char *definition, protocol_str = "udp"; } else if(strncmp(ip, "unix:", 5) == 0) { - ip += 5; + char *path = ip + 5; socktype = SOCK_STREAM; protocol_str = "unix"; - unix_socket=1; + int fd = create_listen_socket_unix(path, listen_backlog); + if (fd == -1) { + error("LISTENER: Cannot create unix socket '%s'", path); + sockets->failed++; + } else { + 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; + listen_sockets_add(sockets, fd, AF_UNIX, socktype, protocol_str, path, 0, acl_flags); + added++; + } + return added; } char *e = ip; @@ -394,18 +402,6 @@ static inline int bind_to_this(LISTEN_SOCKETS *sockets, const char *definition, 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; } - if (unix_socket) { - int fd = create_listen_socket_unix(port, listen_backlog); - if (fd == -1) { - error("LISTENER: Cannot create unix socket '%s'", port); - sockets->failed++; - } else { - listen_sockets_add(sockets, fd, AF_UNIX, socktype, protocol_str, port, 0, acl_flags); - added++; - } - return added; - } - uint32_t scope_id = 0; if(*interface) { scope_id = if_nametoindex(interface); |