]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm: refuse to run trigger, control, settle and monitor commands in chroot
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Jan 2019 05:30:55 +0000 (14:30 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Jan 2019 09:31:19 +0000 (10:31 +0100)
Closes #11333.

src/udev/udevadm-control.c
src/udev/udevadm-monitor.c
src/udev/udevadm-settle.c
src/udev/udevadm-trigger.c

index d9320418cf8ec7382fe3faa1344e72771bf1c6f8..cb9b4cc89ee869506c5109925be0fd2622be186e 100644 (file)
@@ -26,6 +26,7 @@
 #include "udevadm.h"
 #include "udev-ctrl.h"
 #include "util.h"
+#include "virt.h"
 
 static int help(void) {
         printf("%s control OPTION\n\n"
@@ -70,6 +71,11 @@ int control_main(int argc, char *argv[], void *userdata) {
         if (r < 0)
                 return r;
 
+        if (running_in_chroot() > 0) {
+                log_info("Running in chroot, ignoring request.");
+                return 0;
+        }
+
         if (argc <= 1)
                 log_error("Option missing");
 
index f7737d079089db6f347c4f2bf51d6856b7db25a7..f1b3e25cdda4d6a81664c8a85bff4adaa2c9e42d 100644 (file)
@@ -17,6 +17,7 @@
 #include "signal-util.h"
 #include "string-util.h"
 #include "udevadm.h"
+#include "virt.h"
 
 static bool arg_show_property = false;
 static bool arg_print_kernel = false;
@@ -210,6 +211,11 @@ int monitor_main(int argc, char *argv[], void *userdata) {
         if (r <= 0)
                 goto finalize;
 
+        if (running_in_chroot() > 0) {
+                log_info("Running in chroot, ignoring request.");
+                return 0;
+        }
+
         /* Callers are expecting to see events as they happen: Line buffering */
         setlinebuf(stdout);
 
index 4ae237d430b97a720858b260a824f95c166f6b36..9b05e9acf06592c9252d13a6d1f7992b0eb7667b 100644 (file)
@@ -18,6 +18,7 @@
 #include "udevadm.h"
 #include "udev-ctrl.h"
 #include "util.h"
+#include "virt.h"
 
 static usec_t arg_timeout = 120 * USEC_PER_SEC;
 static const char *arg_exists = NULL;
@@ -88,6 +89,11 @@ int settle_main(int argc, char *argv[], void *userdata) {
         if (r <= 0)
                 return r;
 
+        if (running_in_chroot() > 0) {
+                log_info("Running in chroot, ignoring request.");
+                return 0;
+        }
+
         deadline = now(CLOCK_MONOTONIC) + arg_timeout;
 
         /* guarantee that the udev daemon isn't pre-processing */
index f13a08f3f93a347182e171b10932a61bee4f6dee..aa9ebd5ac575c1a680f032652f39e53659099425 100644 (file)
@@ -15,6 +15,7 @@
 #include "strv.h"
 #include "udevadm.h"
 #include "udevadm-util.h"
+#include "virt.h"
 
 static bool arg_verbose = false;
 static bool arg_dry_run = false;
@@ -158,6 +159,11 @@ int trigger_main(int argc, char *argv[], void *userdata) {
         bool settle = false;
         int c, r;
 
+        if (running_in_chroot() > 0) {
+                log_info("Running in chroot, ignoring request.");
+                return 0;
+        }
+
         r = sd_device_enumerator_new(&e);
         if (r < 0)
                 return r;