summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-12-22 10:28:05 +0100
committerLennart Poettering <lennart@poettering.net>2022-12-23 18:09:02 +0100
commit5f4c9c27d8507fc079e7dd0d448cab097491c85f (patch)
treefb9ac4e5b386390224be5f828d1434816b34397e
parentc2c38276cb3185f1c383cffe77635bc1411dbc2c (diff)
downloadsystemd-5f4c9c27d8507fc079e7dd0d448cab097491c85f.tar.gz
core: tighten validation checks in SwitchRoot() dbus call
-rw-r--r--src/core/dbus-manager.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 9e529d6375..ed91e9a1cf 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1680,9 +1680,9 @@ static int method_switch_root(sd_bus_message *message, void *userdata, sd_bus_er
if (r < 0)
return r;
- if (isempty(root))
+ if (!path_is_valid(root))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
- "New root directory may not be the empty string.");
+ "New root directory must be a valid path.");
if (!path_is_absolute(root))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
"New root path '%s' is not absolute.", root);
@@ -1704,6 +1704,10 @@ static int method_switch_root(sd_bus_message *message, void *userdata, sd_bus_er
} else {
_cleanup_free_ char *chased = NULL;
+ if (!path_is_valid(init))
+ return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
+ "Path to init binary '%s' is not a valid path.", init);
+
if (!path_is_absolute(init))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
"Path to init binary '%s' not absolute.", init);