From 7e4a8a54221adf00cd3eb45a24b633ce61400570 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Thu, 28 Jul 2022 16:10:32 +0200 Subject: [PATCH] Disallowed abstract unix socket syntax in non-Linux systems. The previous commit added/fixed support for abstract Unix domain sockets on Linux with a leading '@' or '\0'. To be consistent in all platforms, treat those prefixes as markers for abstract sockets in all platforms, and fail if abstract sockets are not supported by the platform. That will avoid mistakes when copying a config file from a Linux system and using it in non-Linux, which would surprisingly create a normal socket. --- docs/changes.xml | 6 ++++++ src/nxt_sockaddr.c | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/changes.xml b/docs/changes.xml index 27fffc4c..85749bff 100644 --- a/docs/changes.xml +++ b/docs/changes.xml @@ -37,6 +37,12 @@ increased the applications' startup timeout. + + +disallowed abstract Unix domain socket syntax in non-Linux systems. + + + supporting abstract UNIX sockets. diff --git a/src/nxt_sockaddr.c b/src/nxt_sockaddr.c index 8220590e..86c3335e 100644 --- a/src/nxt_sockaddr.c +++ b/src/nxt_sockaddr.c @@ -601,8 +601,6 @@ nxt_sockaddr_unix_parse(nxt_mp_t *mp, nxt_str_t *addr) socklen = offsetof(struct sockaddr_un, sun_path) + length + 1; -#if (NXT_LINUX) - /* * Linux unix(7): * @@ -615,9 +613,12 @@ nxt_sockaddr_unix_parse(nxt_mp_t *mp, nxt_str_t *addr) if (path[0] == '@') { path[0] = '\0'; socklen--; - } - +#if !(NXT_LINUX) + nxt_thread_log_error(NXT_LOG_ERR, + "abstract unix domain sockets are not supported"); + return NULL; #endif + } sa = nxt_sockaddr_alloc(mp, socklen, addr->length);