diff options
author | Luca Boccassi <luca.boccassi@microsoft.com> | 2021-10-27 12:59:19 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-10-27 20:56:24 +0200 |
commit | 69e0830994a7156e4ea16cba2be9c34e8b56608d (patch) | |
tree | 44114ea3eda855df2224322613b19363e95a6fe4 /src/run/run.c | |
parent | Merge pull request #21138 from bluca/show_extensions (diff) | |
download | systemd-69e0830994a7156e4ea16cba2be9c34e8b56608d.tar.xz systemd-69e0830994a7156e4ea16cba2be9c34e8b56608d.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | src/run/run.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/run/run.c b/src/run/run.c index 29ab3f3392..bf2bd29bc0 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. */ |