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>
Sun, 20 Sep 2020 09:43:01 +0000 (11:43 +0200)
Follow-up for bf331d87171b7750d1c72ab0b140a240c0cf32c3.

(cherry picked from commit d31f33e3c9f6ea3bdc873ee52f4398edbec74527)
(cherry picked from commit 3bf7797f1f5d2c97d3b4c108ca487f8d337e8af2)

src/network/networkd-manager.c

index f1549f733f96c45b9cb8735673575ab454dfe41d..7457ced469d154ebc9e057924f822cda12dcdf72 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)
@@ -249,10 +249,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);