From: Luca Boccassi Date: Wed, 27 Oct 2021 10:59:19 +0000 (+0100) Subject: run: do not validate exe early if MountImages/ExtensionImages are used X-Git-Tag: v250-rc1~406 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=69e0830994a7156e4ea16cba2be9c34e8b56608d;p=thirdparty%2Fsystemd.git run: do not validate exe early if MountImages/ExtensionImages are used Same as with RootImage&friends, the executable might be in the image, so it's not visible in the host before the unit is set up. --- diff --git a/src/run/run.c b/src/run/run.c index 29ab3f33929..bf2bd29bc01 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -1698,6 +1698,21 @@ static int start_transient_trigger( return 0; } +static bool shall_make_executable_absolute(void) { + const char *f; + + if (strv_isempty(arg_cmdline)) + return false; + if (arg_transport != BUS_TRANSPORT_LOCAL) + return false; + + FOREACH_STRING(f, "RootDirectory=", "RootImage=", "ExecSearchPath=", "MountImages=", "ExtensionImages=") + if (strv_find_startswith(arg_property, f)) + return false; + + return true; +} + static int run(int argc, char* argv[]) { _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; _cleanup_free_ char *description = NULL; @@ -1711,11 +1726,7 @@ static int run(int argc, char* argv[]) { if (r <= 0) return r; - if (!strv_isempty(arg_cmdline) && - arg_transport == BUS_TRANSPORT_LOCAL && - !strv_find_startswith(arg_property, "RootDirectory=") && - !strv_find_startswith(arg_property, "ExecSearchPath=") && - !strv_find_startswith(arg_property, "RootImage=")) { + if (shall_make_executable_absolute()) { /* Patch in an absolute path to fail early for user convenience, but only when we can do it * (i.e. we will be running from the same file system). This also uses the user's $PATH, * while we use a fixed search path in the manager. */