From 160649b7673392a9084be0492ac65a332d42cbd0 Mon Sep 17 00:00:00 2001 From: Matt Schatz Date: Thu, 9 Apr 2020 06:47:53 -0600 Subject: Set Unix socket permissions after binding. --- src/listensocket.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/listensocket.cpp b/src/listensocket.cpp index 8c5fda59a..d7217650e 100644 --- a/src/listensocket.cpp +++ b/src/listensocket.cpp @@ -83,6 +83,11 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_t #endif } + SocketEngine::SetReuse(fd); + int rv = SocketEngine::Bind(this->fd, bind_to); + if (rv >= 0) + rv = SocketEngine::Listen(this->fd, ServerInstance->Config->MaxConn); + if (bind_to.family() == AF_UNIX) { const std::string permissionstr = tag->getString("permissions"); @@ -91,11 +96,6 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_t chmod(bind_to.str().c_str(), permissions); } - SocketEngine::SetReuse(fd); - int rv = SocketEngine::Bind(this->fd, bind_to); - if (rv >= 0) - rv = SocketEngine::Listen(this->fd, ServerInstance->Config->MaxConn); - // Default defer to on for TLS listeners because in TLS the client always speaks first int timeout = tag->getDuration("defer", (tag->getString("ssl").empty() ? 0 : 3)); if (timeout && !rv) -- cgit v1.2.3