diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-04-20 22:42:58 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-04-20 22:42:58 +0200 |
commit | e7d01040692b5d7155038e68cca31217aa804129 (patch) | |
tree | 46306282b3b3cb86b30519a40910e57e2e8954af /src | |
parent | create and bind socket (diff) | |
download | mds-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 'src')
-rw-r--r-- | src/mds.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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)) |