From fc6882305f0b5e06e58a0a25740f422d133015b5 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 1 Nov 2020 22:05:35 -0800 Subject: fixes #1041 Abstract socket address for IPC fixes #1326 Linux IPC could use fchmod fixes #1327 getsockname on ipc may not work This introduces an abstract:// style transport, which on Linux results in using the abstract socket with the given name (not including the leading NULL byte). A new NNG_AF_ABSTRACT is provided. Auto bind abstract sockets are also supported. While here we have inlined the aios for the POSIX ipc pipe objects, eliminating at least one set of failure paths, and have also performed various other cleanups. A unix:// alias is available on POSIX systems, which acts just like ipc:// (and is fact just an alias). This is supplied so that in the future we can add support for AF_UNIX on Windows. We've also absorbed the ipcperms test into the new ipc_test suite. Finally we are now enforcing that IPC path names on Windows are not over the maximum size, rather than just silently truncating them. --- src/platform/posix/posix_tcpdial.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/platform/posix/posix_tcpdial.c') diff --git a/src/platform/posix/posix_tcpdial.c b/src/platform/posix/posix_tcpdial.c index 9b3a91f5..767717af 100644 --- a/src/platform/posix/posix_tcpdial.c +++ b/src/platform/posix/posix_tcpdial.c @@ -321,7 +321,7 @@ tcp_dialer_get_locaddr(void *arg, void *buf, size_t *szp, nni_type t) nng_sockaddr sa; nni_mtx_lock(&d->mtx); - if (nni_posix_sockaddr2nn(&sa, &d->src) != 0) { + if (nni_posix_sockaddr2nn(&sa, &d->src, d->srclen) != 0) { sa.s_family = NNG_AF_UNSPEC; } nni_mtx_unlock(&d->mtx); @@ -336,13 +336,13 @@ tcp_dialer_set_locaddr(void *arg, const void *buf, size_t sz, nni_type t) struct sockaddr_storage ss; struct sockaddr_in * sin; struct sockaddr_in6 * sin6; - size_t sslen; + size_t len; int rv; if ((rv = nni_copyin_sockaddr(&sa, buf, sz, t)) != 0) { return (rv); } - if ((sslen = nni_posix_nn2sockaddr(&ss, &sa)) == 0) { + if ((len = nni_posix_nn2sockaddr(&ss, &sa)) == 0) { return (NNG_EADDRINVAL); } // Ensure we are either IPv4 or IPv6, and port is not set. (We @@ -370,7 +370,7 @@ tcp_dialer_set_locaddr(void *arg, const void *buf, size_t sz, nni_type t) return (NNG_ECLOSED); } d->src = ss; - d->srclen = sslen; + d->srclen = len; nni_mtx_unlock(&d->mtx); } return (0); -- cgit v1.2.3-70-g09d2