]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
run: let systemd resolve the path with RootDirectory=/RootImage= 17143/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 17 Sep 2020 13:44:59 +0000 (15:44 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 23 Sep 2020 12:49:37 +0000 (14:49 +0200)
Fixes #13338.

src/core/dbus-execute.c
src/run/run.c

index dfcc2ee6e72930514600b2f298e457dec450ebae..753b91d511a7ec3a59fc59049f0acf8f2ffeef38 100644 (file)
@@ -1354,8 +1354,10 @@ int bus_set_transient_exec_command(
                 if (r < 0)
                         return r;
 
-                if (!path_is_absolute(path))
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path %s is not absolute.", path);
+                if (!path_is_absolute(path) && !filename_is_valid(path))
+                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
+                                                 "\"%s\" is neither a valid executable name nor an absolute path",
+                                                 path);
 
                 r = sd_bus_message_read_strv(message, &argv);
                 if (r < 0)
index bdd82c085a1d3a4e2e442c546147d88bb96c698e..214b2695695e6fe5cbb009e42636ea0853f2facd 100644 (file)
@@ -1720,11 +1720,15 @@ static int run(int argc, char* argv[]) {
         if (r <= 0)
                 return r;
 
-        if (!strv_isempty(arg_cmdline) && arg_transport == BUS_TRANSPORT_LOCAL) {
-                _cleanup_free_ char *command = NULL;
-
-                /* Patch in an absolute path */
+        if (!strv_isempty(arg_cmdline) &&
+            arg_transport == BUS_TRANSPORT_LOCAL &&
+            !strv_find_startswith(arg_property, "RootDirectory=") &&
+            !strv_find_startswith(arg_property, "RootImage=")) {
+                /* 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. */
 
+                _cleanup_free_ char *command = NULL;
                 r = find_executable(arg_cmdline[0], &command);
                 if (r < 0)
                         return log_error_errno(r, "Failed to find executable %s: %m", arg_cmdline[0]);