]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
ply-utils: Create parent directory before binding concrete socket 359/head
authorAlessandro Astone <alessandro.astone@canonical.com>
Tue, 22 Jul 2025 07:40:43 +0000 (09:40 +0200)
committerAlessandro Astone <alessandro.astone@canonical.com>
Tue, 22 Jul 2025 07:41:36 +0000 (09:41 +0200)
bind()'ing a concrete socket requires that the parent directory exists already.

src/libply/ply-utils.c

index d8d28c08a6f423b44792c415d5aaa5e8914710a9..f227589f759864cd743baa63a3ee68b681d558a7 100644 (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);