diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index dfcc2ee6e7..753b91d511 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -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) diff --git a/src/run/run.c b/src/run/run.c index bdd82c085a..214b269569 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -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) { + 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; - - /* Patch in an absolute path */ - r = find_executable(arg_cmdline[0], &command); if (r < 0) return log_error_errno(r, "Failed to find executable %s: %m", arg_cmdline[0]);