]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: convert copy_devnodes():devnodes from nulstr to strv
authorLuke T. Shumaker <lukeshu@parabola.nu>
Wed, 21 Aug 2024 23:17:02 +0000 (17:17 -0600)
committerLuke T. Shumaker <lukeshu@parabola.nu>
Sat, 7 Sep 2024 00:33:50 +0000 (18:33 -0600)
src/nspawn/nspawn.c

index 8fd307b1d893530bb3364d4f2c7184305abecdfa..0cb26cbc31232c0754ee5c16de9a21fdb61dd2d8 100644 (file)
@@ -2148,30 +2148,32 @@ static int setup_boot_id(void) {
 }
 
 static int copy_devnodes(const char *dest) {
-        static const char devnodes[] =
-                "null\0"
-                "zero\0"
-                "full\0"
-                "random\0"
-                "urandom\0"
-                "tty\0"
-                "net/tun\0";
-
+        _cleanup_strv_free_ char **devnodes = NULL;
         int r = 0;
 
         assert(dest);
 
+        devnodes = strv_new("null",
+                            "zero",
+                            "full",
+                            "random",
+                            "urandom",
+                            "tty",
+                            "net/tun");
+        if (!devnodes)
+                return log_oom();
+
         BLOCK_WITH_UMASK(0000);
 
         /* Create /dev/net, so that we can create /dev/net/tun in it */
         if (userns_mkdir(dest, "/dev/net", 0755, 0, 0) < 0)
                 return log_error_errno(r, "Failed to create /dev/net directory: %m");
 
-        NULSTR_FOREACH(d, devnodes) {
+        STRV_FOREACH(d, devnodes) {
                 _cleanup_free_ char *from = NULL, *to = NULL;
                 struct stat st;
 
-                from = path_join("/dev/", d);
+                from = path_join("/dev/", *d);
                 if (!from)
                         return log_oom();
 
@@ -2225,7 +2227,7 @@ static int copy_devnodes(const char *dest) {
                         if (!prefixed)
                                 return log_oom();
 
-                        t = path_join("..", d);
+                        t = path_join("..", *d);
                         if (!t)
                                 return log_oom();