aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-04-12 04:07:18 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-12 04:07:18 +0000
commitd4f319deafc41d000c7e249e1acfe9626dec52a8 (patch)
treec123d64916e46206eb02ecf82fd945766af32198
parent623a86f389dc3c1cce52b1d0e6ef64d27b26f023 (diff)
downloadmpd-d4f319deafc41d000c7e249e1acfe9626dec52a8.tar.gz
mpd-d4f319deafc41d000c7e249e1acfe9626dec52a8.tar.xz
mpd-d4f319deafc41d000c7e249e1acfe9626dec52a8.zip
support listening on unix domain sockets
This trivial patch addresses bug 1639. When a bind_to_address argument starts with a slash, assume that it is the address of a Unix domain socket. git-svn-id: https://svn.musicpd.org/mpd/trunk@7235 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--src/listen.c16
-rw-r--r--src/os_compat.h1
2 files changed, 17 insertions, 0 deletions
diff --git a/src/listen.c b/src/listen.c
index 78bb6ace1..423b54e9a 100644
--- a/src/listen.c
+++ b/src/listen.c
@@ -157,6 +157,22 @@ static void parseListenConfigParam(unsigned int port, ConfigParam * param)
#endif
BINDERROR();
}
+ } else if (param->value[0] == '/') {
+ size_t path_length;
+ struct sockaddr_un sun;
+
+ path_length = strlen(param->value);
+ if (path_length >= sizeof(sun.sun_path))
+ FATAL("unix socket path is too long\n");
+
+ sun.sun_family = AF_UNIX;
+ memcpy(sun.sun_path, param->value, path_length + 1);
+
+ addrp = (const struct sockaddr *)&sun;
+ addrlen = sizeof(sun);
+
+ if (establishListen(addrp, addrlen) < 0)
+ BINDERROR();
} else {
struct hostent *he;
DEBUG("binding to address for %s\n", param->value);
diff --git a/src/os_compat.h b/src/os_compat.h
index c6268d0d8..6409053c7 100644
--- a/src/os_compat.h
+++ b/src/os_compat.h
@@ -64,6 +64,7 @@
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <sys/un.h>
#include <pwd.h>
#include <grp.h>
#include <limits.h>