]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
run: Don't make executable absolute when --root-directory= is used
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 24 Nov 2025 18:52:40 +0000 (19:52 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 25 Nov 2025 23:37:17 +0000 (00:37 +0100)
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

index c0553c7bd9fd7b386be9afba18800399afd787cf..088c30edcd292168b65aca026accb49c395f328a 100644 (file)
@@ -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))