1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-06 13:17:44 +03:00

udevadm: refuse to run trigger, control, settle and monitor commands in chroot

Closes #11333.
This commit is contained in:
Yu Watanabe 2019-01-07 14:30:55 +09:00 committed by Zbigniew Jędrzejewski-Szmek
parent 787a133f2d
commit c494b739a4
4 changed files with 24 additions and 0 deletions

View 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");

View 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);

View 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 */

View 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;