fs: Make the full directory path for the pid file and the control socket
Build systems should not attempt to create $runstatedir (or anything
under it). Doing so causes warnings in packaging systems, such as in
Alpine Linux, as reported by Andy.
But unitd(8) can be configured to be installed under /opt, or other
trees, where no directories exist before hand. Expecting that the user
creates the entire directory trees that unit will need is a bit
unreasonable. Instead, let's just create any directories that we need,
with all their parents, at run time.
Fixes: 57fc9201cb
("Socket: Created control socket & pid file directories.")
Link: <https://github.com/nginx/unit/issues/742>
Reported-by: Andy Postnikov <apostnikov@gmail.com>
Tested-by: Andy Postnikov <apostnikov@gmail.com>
Tested-by: Andrew Clayton <a.clayton@nginx.com>
Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Acked-by: Konstantin Pavlov <thresh@nginx.com>
Cc: Liam Crilly <liam@nginx.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
parent
a9aed2044c
commit
eca38349cb
4 changed files with 5 additions and 5 deletions
|
@ -695,7 +695,7 @@ nxt_runtime_controller_socket(nxt_task_t *task, nxt_runtime_t *rt)
|
|||
if (ls->sockaddr->u.sockaddr.sa_family == AF_UNIX) {
|
||||
const char *path = ls->sockaddr->u.sockaddr_un.sun_path;
|
||||
|
||||
nxt_fs_mkdir_dirname((const u_char *) path, 0755);
|
||||
nxt_fs_mkdir_p_dirname((const u_char *) path, 0755);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ nxt_fs_mkdir_p(const u_char *dir, mode_t mode)
|
|||
|
||||
|
||||
nxt_int_t
|
||||
nxt_fs_mkdir_dirname(const u_char *path, mode_t mode)
|
||||
nxt_fs_mkdir_p_dirname(const u_char *path, mode_t mode)
|
||||
{
|
||||
char *ptr, *dir;
|
||||
nxt_int_t ret;
|
||||
|
@ -64,7 +64,7 @@ nxt_fs_mkdir_dirname(const u_char *path, mode_t mode)
|
|||
}
|
||||
|
||||
*ptr = '\0';
|
||||
ret = nxt_fs_mkdir((const u_char *) dir, mode);
|
||||
ret = nxt_fs_mkdir_p((const u_char *) dir, mode);
|
||||
|
||||
out_free:
|
||||
nxt_free(dir);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#define _NXT_FS_H_INCLUDED_
|
||||
|
||||
|
||||
nxt_int_t nxt_fs_mkdir_dirname(const u_char *path, mode_t mode);
|
||||
nxt_int_t nxt_fs_mkdir_p_dirname(const u_char *path, mode_t mode);
|
||||
nxt_int_t nxt_fs_mkdir_p(const u_char *dir, mode_t mode);
|
||||
|
||||
|
||||
|
|
|
@ -1490,7 +1490,7 @@ nxt_runtime_pid_file_create(nxt_task_t *task, nxt_file_name_t *pid_file)
|
|||
|
||||
file.name = pid_file;
|
||||
|
||||
nxt_fs_mkdir_dirname(pid_file, 0755);
|
||||
nxt_fs_mkdir_p_dirname(pid_file, 0755);
|
||||
|
||||
n = nxt_file_open(task, &file, O_WRONLY, O_CREAT | O_TRUNC,
|
||||
NXT_FILE_DEFAULT_ACCESS);
|
||||
|
|
Loading…
Reference in a new issue