]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: use FOREACH_STRING()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 24 Feb 2024 05:25:54 +0000 (14:25 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 24 Feb 2024 12:04:14 +0000 (21:04 +0900)
src/network/networkd.c

index 46c2c743467fcb01980f82b158c38a07cab5e04b..3384c7c3eae094eb9ad6d00d87e2f922ac11ef06 100644 (file)
@@ -18,6 +18,7 @@
 #include "networkd-manager.h"
 #include "service-util.h"
 #include "signal-util.h"
+#include "strv.h"
 #include "user-util.h"
 
 static int run(int argc, char *argv[]) {
@@ -69,17 +70,14 @@ static int run(int argc, char *argv[]) {
         /* Always create the directories people can create inotify watches in.
          * It is necessary to create the following subdirectories after drop_privileges()
          * to support old kernels not supporting AmbientCapabilities=. */
-        r = mkdir_safe_label("/run/systemd/netif/links", 0755, UID_INVALID, GID_INVALID, MKDIR_WARN_MODE);
-        if (r < 0)
-                log_warning_errno(r, "Could not create runtime directory 'links': %m");
-
-        r = mkdir_safe_label("/run/systemd/netif/leases", 0755, UID_INVALID, GID_INVALID, MKDIR_WARN_MODE);
-        if (r < 0)
-                log_warning_errno(r, "Could not create runtime directory 'leases': %m");
-
-        r = mkdir_safe_label("/run/systemd/netif/lldp", 0755, UID_INVALID, GID_INVALID, MKDIR_WARN_MODE);
-        if (r < 0)
-                log_warning_errno(r, "Could not create runtime directory 'lldp': %m");
+        FOREACH_STRING(p,
+                       "/run/systemd/netif/links/",
+                       "/run/systemd/netif/leases/",
+                       "/run/systemd/netif/lldp/") {
+                r = mkdir_safe_label(p, 0755, UID_INVALID, GID_INVALID, MKDIR_WARN_MODE);
+                if (r < 0)
+                        log_warning_errno(r, "Could not create directory '%s': %m", p);
+        }
 
         r = manager_new(&m, /* test_mode = */ false);
         if (r < 0)