diff options
-rw-r--r-- | src/event/ServerSocket.cxx | 8 | ||||
-rw-r--r-- | src/net/SocketUtil.cxx | 10 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/event/ServerSocket.cxx b/src/event/ServerSocket.cxx index 12576d2a2..93e9e911f 100644 --- a/src/event/ServerSocket.cxx +++ b/src/event/ServerSocket.cxx @@ -39,7 +39,6 @@ #include <string> #include <algorithm> -#include <sys/stat.h> #include <string.h> #include <unistd.h> #include <assert.h> @@ -184,13 +183,6 @@ OneServerSocket::Open() SOCK_STREAM, 0, address, 5); -#ifdef HAVE_UN - /* allow everybody to connect */ - - if (!path.IsNull()) - fchmod(_fd.Get(), 0666); -#endif - /* register in the EventLoop */ SetFD(_fd.Release()); diff --git a/src/net/SocketUtil.cxx b/src/net/SocketUtil.cxx index 6882f8958..de2c25917 100644 --- a/src/net/SocketUtil.cxx +++ b/src/net/SocketUtil.cxx @@ -23,6 +23,8 @@ #include "SocketError.hxx" #include "UniqueSocketDescriptor.hxx" +#include <sys/stat.h> + UniqueSocketDescriptor socket_bind_listen(int domain, int type, int protocol, SocketAddress address, @@ -32,6 +34,14 @@ socket_bind_listen(int domain, int type, int protocol, if (!fd.CreateNonBlock(domain, type, protocol)) throw MakeSocketError("Failed to create socket"); + +#ifdef HAVE_UN + if (domain == AF_UNIX) { + /* allow everybody to connect */ + fchmod(fd.Get(), 0666); + } +#endif + if (!fd.SetReuseAddress()) throw MakeSocketError("setsockopt() failed"); |