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)
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]);