From 2ba910ab06e5970e9e2dc6d28a8d38a4adcd4a16 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 24 Nov 2025 19:52:40 +0100 Subject: [PATCH] run: Don't make executable absolute when --root-directory= is used Also, unless --same-root-dir was specified, don't make the executable absolute if we're running in a chroot. Situations like this are still iffy, but we might as well handle them a little more gracefully. --- src/run/run.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/run/run.c b/src/run/run.c index c0553c7bd9f..088c30edcd2 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -65,6 +65,7 @@ #include "unit-def.h" #include "unit-name.h" #include "user-util.h" +#include "virt.h" static bool arg_ask_password = true; static bool arg_scope = false; @@ -3055,6 +3056,12 @@ static bool shall_make_executable_absolute(void) { return false; if (arg_transport != BUS_TRANSPORT_LOCAL) return false; + if (!empty_or_root(arg_root_directory)) + return false; + /* If we're running in a chroot, our view of the filesystem might be completely different from pid1's + * view of the filesystem, hence don't try to resolve the executable in that case. */ + if (!arg_root_directory && running_in_chroot() > 0) + return false; FOREACH_STRING(f, "RootDirectory=", "RootImage=", "ExecSearchPath=", "MountImages=", "ExtensionImages=") if (strv_find_startswith(arg_property, f)) -- 2.47.3