ply-utils: Create parent directory before binding concrete socket

bind()'ing a concrete socket requires that the parent directory exists already.
This commit is contained in:
Alessandro Astone 2025-07-22 09:40:43 +02:00
parent 287ae4de45
commit a0c2e66529

View file

@ -27,6 +27,7 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
@ -223,6 +224,12 @@ ply_listen_to_unix_socket (const char *path,
address = create_unix_address_from_path (path, type, &address_size);
if (type == PLY_UNIX_SOCKET_TYPE_CONCRETE) {
char *writable_path = strdup (path);
ply_create_directory (dirname (writable_path));
free (writable_path);
}
if (bind (fd, address, address_size) < 0) {
ply_save_errno ();
free (address);