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.
This commit is contained in:
Alejandro Colomar
2022-07-28 16:10:32 +02:00
parent e2aec6686a
commit 7e4a8a5422
2 changed files with 11 additions and 4 deletions

View File

@@ -37,6 +37,12 @@ increased the applications' startup timeout.
</para>
</change>
<change type="change">
<para>
disallowed abstract Unix domain socket syntax in non-Linux systems.
</para>
</change>
<change type="feature">
<para>
supporting abstract UNIX sockets.

View File

@@ -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);