From 5fe5bbb45546d7ae7c16e413cc6514d46cc3d9ee Mon Sep 17 00:00:00 2001 From: Petr Baudis <pasky@ucw.cz> Date: Thu, 1 Mar 2012 03:41:25 +0100 Subject: [PATCH] compctld: Fix few issues with the creation of socket file --- compctld.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compctld.c b/compctld.c index 35d6bf4..ad1283f 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; -- GitLab