Commit d4f319de authored by Max Kellermann's avatar Max Kellermann Committed by Eric Wong

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
parent 623a86f3
......@@ -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);
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment