Commit 5fe5bbb4 authored by Petr Baudis's avatar Petr Baudis
Browse files

compctld: Fix few issues with the creation of socket file

parent c9a27c95
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment