diff --git a/compctld.c b/compctld.c index 35d6bf47d6f17adfabfb83c8d66d78f24acca9e1..ad1283f93162d186e2aed3780ea9ccd6222b6d39 100644 --- a/compctld.c +++ b/compctld.c @@ -5,6 +5,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/stat.h> #include <sys/socket.h> #include <sys/un.h> #include <syslog.h> @@ -101,12 +102,14 @@ main(int argc, char *argv[]) int s = socket(AF_UNIX, SOCK_STREAM, 0); int on = 1; setsockopt(s, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)); + /* TODO: Protect against double execution? */ + unlink(SOCKFILE); struct sockaddr_un sun = { .sun_family = AF_UNIX, .sun_path = SOCKFILE }; if (bind(s, (struct sockaddr *) &sun, sizeof(sun.sun_family) + strlen(sun.sun_path) + 1) < 0) { logperror(SOCKFILE); exit(EXIT_FAILURE); } - + chmod(SOCKFILE, 0777); listen(s, 10); int fd;