Fix service file specifying 'Run in terminal' giving an error code 100
ClosedPublic

Authored by marten on May 14 2020, 9:40 AM.

Details

Summary

https://bugs.kde.org/show_bug.cgi?id=421374 describes how a service file specified to run in a terminal gives an error saying that it cannot find 'konsole' or the user's configured terminal program.

The problem is that KIO::DesktopExecParser::resultingArguments(), if service.terminal() is true, prepends the terminal application to the command line. If this is a relative path, as it is most likely to be (and will be in the default 'konsole' case), the "realExecutable" check in KProcessRunner::KProcessRunner() is triggered and the job aborts with an error message.

This change expands the specified terminal executable into a full path in KIO::DesktopExecParser::resultingArguments(), and returns an error immediately if it cannot be found. This is then prepended to the command line. When KProcessRunner::KProcessRunner() checks the realExecutable (the first word of the command line) it will be an absolute path and the check will not fail.

The order of the code blocks in KProcessRunner::KProcessRunner() is adjusted so that execParser.resultingArguments() is checked for being empty (an error return) before the first word of the command is accessed. This means that the "realExecutable = execParser.resultingArguments().at(0)" test will not assert if resultingArguments() is an empty list.

BUG: 421374
FIXED-IN: 5.71

Test Plan

Built kio with this change, tested with the sample desktop file at https://bugs.kde.org/show_bug.cgi?id=421374#c8. The command correctly runs in a terminal.

Diff Detail

Repository
R241 KIO
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
marten created this revision.May 14 2020, 9:40 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptMay 14 2020, 9:40 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
marten requested review of this revision.May 14 2020, 9:40 AM
ngraham edited the summary of this revision. (Show Details)May 14 2020, 3:10 PM
dfaure accepted this revision.May 14 2020, 5:19 PM

Nice! In addition to the bugfix, calling resultingArguments() only once is a definite improvement, given everything that happens in there. I didn't realize we were calling it twice.

This revision is now accepted and ready to land.May 14 2020, 5:19 PM
This revision was automatically updated to reflect the committed changes.

Well spotted. Indeed, when using kioexec (because of the DeleteTemporaryFiles option) we no longer detect non-existing executables. I'll look into fixing this.