[PATCH] updated support for unix socket in abstract namespace

Roberto De Ioris roberto at unbit.it
Sat Jun 4 09:27:07 MSD 2011


Hi all,
attached there is an updated patch for adding support for unix socket in
abstract namespace.

As requested by Igor, the syntax is now

unix:\0foobar

instead of

unix:@foobar

The only relevant note is this part of code:

+    if (saun->sun_path[0] != '\0') {
+        u->addrs[0].socklen = sizeof(struct sockaddr_un);
+    }
+    else {
+        u->addrs[0].socklen = sizeof(saun->sun_family) + len;
+    }


it looks like using

u->addrs[0].socklen = sizeof(saun->sun_family) + len;

is not reliable in all os (NetBSD and OpenBSD in my tests did not work) so
i think
an exception (as i did) is more "secure".

Probably, as linux is the only os supporting abstract namespace, we could
use:

#ifdef __linux__
    u->addrs[0].socklen = sizeof(saun->sun_family) + len;
#else
    u->addrs[0].socklen = sizeof(struct sockaddr_un);
#endif

-- 
Roberto De Ioris
http://unbit.it
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nginx_unix_abstract.patch
Type: application/octet-stream
Size: 1812 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx/attachments/20110604/1c82fc60/attachment.obj>


More information about the nginx mailing list