aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-04-20 22:42:58 +0200
committerMattias Andrée <maandree@operamail.com>2014-04-20 22:42:58 +0200
commite7d01040692b5d7155038e68cca31217aa804129 (patch)
tree46306282b3b3cb86b30519a40910e57e2e8954af /src/mds.c
parentcreate and bind socket (diff)
downloadmds-e7d01040692b5d7155038e68cca31217aa804129.tar.gz
mds-e7d01040692b5d7155038e68cca31217aa804129.tar.bz2
mds-e7d01040692b5d7155038e68cca31217aa804129.tar.xz
m + listen on socket
Signed-off-by: Mattias Andrée <maandree@operamail.com>
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))