summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 42e0a93)
raw | patch | inline | side by side (parent: 42e0a93)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 29 Jun 2014 18:43:58 +0000 (20:43 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 29 Jun 2014 18:43:58 +0000 (20:43 +0200) |
src/frontend/sock.c | patch | blob | history |
diff --git a/src/frontend/sock.c b/src/frontend/sock.c
index 2e5a6aff66d6484831907c1bcc31fb0b7dd698cb..845274e95606bde06129e4d676657dd9f6db8342 100644 (file)
--- a/src/frontend/sock.c
+++ b/src/frontend/sock.c
#include "utils/channel.h"
#include "utils/error.h"
#include "utils/llist.h"
+#include "utils/os.h"
#include "utils/strbuf.h"
#include <assert.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <libgen.h>
+
#include <pthread.h>
/*
open_unix_sock(listener_t *listener)
{
const char *addr;
+ char *base_dir;
struct sockaddr_un sa;
int status;
sa.sun_family = AF_UNIX;
strncpy(sa.sun_path, addr, sizeof(sa.sun_path));
+ base_dir = strdup(addr);
+ if (! base_dir) {
+ char errbuf[1024];
+ sdb_log(SDB_LOG_ERR, "frontend: strdup failed: %s",
+ sdb_strerror(errno, errbuf, sizeof(errbuf)));
+ return -1;
+ }
+ base_dir = dirname(base_dir);
+
+ /* ensure that the directory exists */
+ if (sdb_mkdir_all(base_dir, 0777)) {
+ char errbuf[1024];
+ sdb_log(SDB_LOG_ERR, "frontend: Failed to create directory '%s': %s",
+ base_dir, sdb_strerror(errno, errbuf, sizeof(errbuf)));
+ free(base_dir);
+ return -1;
+ }
+ free(base_dir);
+
if (unlink(addr) && (errno != ENOENT)) {
char errbuf[1024];
sdb_log(SDB_LOG_WARNING, "frontend: Failed to remove stale UNIX "