network: do not start device monitor if /sys is read-only
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 8 Sep 2020 14:26:28 +0000 (23:26 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 11 Sep 2020 18:01:12 +0000 (20:01 +0200)
Follow-up for bf331d87171b7750d1c72ab0b140a240c0cf32c3.

(cherry picked from commit d31f33e3c9f6ea3bdc873ee52f4398edbec74527)

src/network/networkd-manager.c

index 175917df3b033da2db345cbf6d83d306df57562b..5ca12a9b8604a91f4ea4baeed1ef8d08a6feb2b5 100644 (file)
 #include "path-util.h"
 #include "set.h"
 #include "signal-util.h"
+#include "stat-util.h"
 #include "strv.h"
 #include "sysctl-util.h"
 #include "tmpfile-util.h"
 #include "udev-util.h"
-#include "virt.h"
 
 /* use 128 MB for receive socket kernel queue. */
 #define RCVBUF_SIZE    (128*1024*1024)
@@ -260,10 +260,9 @@ static int manager_udev_process_link(sd_device_monitor *monitor, sd_device *devi
 static int manager_connect_udev(Manager *m) {
         int r;
 
-        /* udev does not initialize devices inside containers,
-         * so we rely on them being already initialized before
-         * entering the container */
-        if (detect_container() > 0)
+        /* udev does not initialize devices inside containers, so we rely on them being already
+         * initialized before entering the container. */
+        if (path_is_read_only_fs("/sys") > 0)
                 return 0;
 
         r = sd_device_monitor_new(&m->device_monitor);