From e5b5c93878f799bb837f977d1bd119ec27bb8e9e Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 9 Jul 2021 17:31:29 -0700 Subject: fixes #1465 NNG_OPT_IPC_PERMISSIONS stopped working This backs out the changes for #1326, because fchmod on sockets doesn't actually work on Linux, even though it returns success. --- src/platform/posix/posix_ipclisten.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'src') diff --git a/src/platform/posix/posix_ipclisten.c b/src/platform/posix/posix_ipclisten.c index f2511487..0fd70851 100644 --- a/src/platform/posix/posix_ipclisten.c +++ b/src/platform/posix/posix_ipclisten.c @@ -284,7 +284,6 @@ ipc_listener_set( return (nni_setopt(ipc_listener_options, name, l, buf, sz, t)); } -#ifndef NNG_PLATFORM_LINUX static int ipc_listener_chmod(ipc_listener *l, const char *path) { @@ -299,7 +298,6 @@ ipc_listener_chmod(ipc_listener *l, const char *path) } return (0); } -#endif int ipc_listener_listen(void *arg) @@ -347,19 +345,6 @@ ipc_listener_listen(void *arg) nni_strfree(path); return (rv); } - // Linux supports fchmod on a socket, which will - // be race condition free. -#ifdef NNG_PLATFORM_LINUX - if ((l->perms != 0) && (path != NULL)) { - if (fchmod(fd, l->perms & ~S_IFMT) != 0) { - rv = nni_plat_errno(errno); - nni_mtx_unlock(&l->mtx); - (void) close(fd); - nni_strfree(path); - return (rv); - } - } -#endif if ((rv = bind(fd, (struct sockaddr *) &ss, len)) != 0) { if ((l->sa.s_family == NNG_AF_IPC) && @@ -372,11 +357,9 @@ ipc_listener_listen(void *arg) path = NULL; } } + if ((rv != 0) || -#ifndef NNG_PLATFORM_LINUX - // Linux uses fchmod instead (which is race free). (ipc_listener_chmod(l, path) != 0) || -#endif (listen(fd, 128) != 0)) { rv = nni_plat_errno(errno); } -- cgit v1.2.3-70-g09d2