summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/nxt_controller.c8
-rw-r--r--src/nxt_fs.c25
-rw-r--r--src/nxt_fs.h1
-rw-r--r--src/nxt_runtime.c2
4 files changed, 36 insertions, 0 deletions
diff --git a/src/nxt_controller.c b/src/nxt_controller.c
index 09168821..99c7ca10 100644
--- a/src/nxt_controller.c
+++ b/src/nxt_controller.c
@@ -666,6 +666,14 @@ nxt_runtime_controller_socket(nxt_task_t *task, nxt_runtime_t *rt)
#endif
ls->handler = nxt_controller_conn_init;
+#if (NXT_HAVE_UNIX_DOMAIN)
+ if (ls->sockaddr->u.sockaddr.sa_family == AF_UNIX) {
+ const char *path = ls->sockaddr->u.sockaddr_un.sun_path;
+
+ nxt_fs_mkdir_parent((const u_char *) path, 0755);
+ }
+#endif
+
if (nxt_listen_socket_create(task, rt->mem_pool, ls) != NXT_OK) {
return NXT_ERROR;
}
diff --git a/src/nxt_fs.c b/src/nxt_fs.c
index 71498f99..35850798 100644
--- a/src/nxt_fs.c
+++ b/src/nxt_fs.c
@@ -273,6 +273,31 @@ nxt_fs_mkdir_all(const u_char *dir, mode_t mode)
}
+nxt_int_t
+nxt_fs_mkdir_parent(const u_char *path, mode_t mode)
+{
+ char *ptr, *dir;
+ nxt_int_t ret;
+
+ dir = nxt_strdup(path);
+ if (nxt_slow_path(dir == NULL)) {
+ return NXT_ERROR;
+ }
+
+ ret = NXT_OK;
+
+ ptr = strrchr(dir, '/');
+ if (nxt_fast_path(ptr != NULL)) {
+ *ptr = '\0';
+ ret = nxt_fs_mkdir((const u_char *) dir, mode);
+ }
+
+ nxt_free(dir);
+
+ return ret;
+}
+
+
static nxt_int_t
nxt_fs_mkdir(const u_char *dir, mode_t mode)
{
diff --git a/src/nxt_fs.h b/src/nxt_fs.h
index ff589979..af9585b8 100644
--- a/src/nxt_fs.h
+++ b/src/nxt_fs.h
@@ -36,6 +36,7 @@ typedef struct {
} nxt_fs_mount_t;
+nxt_int_t nxt_fs_mkdir_parent(const u_char *path, mode_t mode);
nxt_int_t nxt_fs_mkdir_all(const u_char *dir, mode_t mode);
nxt_int_t nxt_fs_mount(nxt_task_t *task, nxt_fs_mount_t *mnt);
void nxt_fs_unmount(const u_char *path);
diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c
index d9c9f2ef..c7e4455e 100644
--- a/src/nxt_runtime.c
+++ b/src/nxt_runtime.c
@@ -1369,6 +1369,8 @@ nxt_runtime_pid_file_create(nxt_task_t *task, nxt_file_name_t *pid_file)
file.name = pid_file;
+ nxt_fs_mkdir_parent(pid_file, 0755);
+
n = nxt_file_open(task, &file, O_WRONLY, O_CREAT | O_TRUNC,
NXT_FILE_DEFAULT_ACCESS);