aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/mds.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mds.c b/src/mds.c
index 639d0a3..d897ecc 100644
--- a/src/mds.c
+++ b/src/mds.c
@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <signal.h>
#include <sys/socket.h>
+#include <sys/un.h>
/**
@@ -184,7 +185,7 @@ int main(int argc_, const char** argv_)
snprintf(pathname, sizeof(pathname) / sizeof(char), "%s/%u.socket",
MDS_RUNTIME_ROOT_DIRECTORY, display);
address.sun_family = AF_UNIX;
- strcpy(address.sun_path, path);
+ strcpy(address.sun_path, pathname);
unlink(pathname);
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if ((fchmod(fd, S_IRWXU) < 0) ||
@@ -201,6 +202,14 @@ int main(int argc_, const char** argv_)
return 1;
}
+ /* Start listening on socket. */
+ if (listen(fd, SOMAXCONN) < 0)
+ {
+ perror(*argv);
+ close(fd);
+ return 1;
+ }
+
/* Drop privileges. They most not be propagated non-authorised components. */
/* setgid should not be set, but just to be safe we are restoring both user and group. */
if ((seteuid(getuid()) < 0) || (setegid(getgid()) < 0))