aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2021-07-09 17:31:29 -0700
committerGarrett D'Amore <garrett@damore.org>2021-07-09 17:32:09 -0700
commite5b5c93878f799bb837f977d1bd119ec27bb8e9e (patch)
tree83f012929ff05173af3a78be63be01d7aaa26323 /src
parent58337cfc78c86fe36a7f6f17c29ad9d24504a52a (diff)
downloadnng-e5b5c93878f799bb837f977d1bd119ec27bb8e9e.tar.gz
nng-e5b5c93878f799bb837f977d1bd119ec27bb8e9e.tar.bz2
nng-e5b5c93878f799bb837f977d1bd119ec27bb8e9e.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/platform/posix/posix_ipclisten.c19
1 files changed, 1 insertions, 18 deletions
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);
}