]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Set Unix socket permissions after binding.
authorMatt Schatz <genius3000@g3k.solutions>
Thu, 9 Apr 2020 12:47:53 +0000 (06:47 -0600)
committerMatt Schatz <genius3000@g3k.solutions>
Thu, 9 Apr 2020 12:57:09 +0000 (06:57 -0600)
src/listensocket.cpp

index 8c5fda59af0731b290b09ab8b89d23a56d4e0245..d7217650e4ffba86e1cedb8a1805c7bcbe422e55 100644 (file)
@@ -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)