Treat "application/x-ms-dos-executable" as executable on all platforms
ClosedPublic

Authored by guoyunhe on Oct 7 2019, 11:11 AM.

Details

Summary

Because of Wine, *.exe can be executed in almost all desktop platforms.

The dialog will open when a script/exe/binary is clicked.

For scripts, it shows "Open" and "Execute" button. Same as before.

For *.exe on Linux/BSD, it shows only "Execute" button, but it actually does "Open with Wine".

For native binary, it shows only "Execute" button. This is a new difference. I think users should never click and run a binary without warning. Here is already a showUntrustedProgramWarning pop up function. But it only popup for binary without execute bit. If you get a binary from *.tar.gz or *.7z, it may already have a execute bit and no popup will be appear.

BUG: 412694

Diff Detail

Repository
R241 KIO
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 17595
Build 17613: arc lint + arc unit
guoyunhe created this revision.Oct 7 2019, 11:11 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptOct 7 2019, 11:11 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
guoyunhe requested review of this revision.Oct 7 2019, 11:11 AM
ngraham edited the summary of this revision. (Show Details)Oct 7 2019, 3:04 PM
ngraham added a subscriber: ngraham.

Maybe can we check to see if WINE is installed or if there's a handler for application/x-ms-dos-executable? Otherwise if you don't have WINE installed, won't you see a dialog that gives you the option to execute it when that doesn't work?

Maybe can we check to see if WINE is installed or if there's a handler for application/x-ms-dos-executable? Otherwise if you don't have WINE installed, won't you see a dialog that gives you the option to execute it when that doesn't work?

It is another feature. We also need to check if PHP/Python/Perl/Ruby/Node.js is installed for other script types. It is not Wine specific problem but a general issue for all executable that requires an interpreter.

ngraham accepted this revision.Oct 7 2019, 3:35 PM
ngraham added a subscriber: dfaure.

I suppose that's true. Would be nice to also do that as a follow-up patch.

Shipit!

@dfaure given the security implications here, maybe we should get this into 5.63. What do you think?

This revision is now accepted and ready to land.Oct 7 2019, 3:35 PM

I just realized that this patch might be unfinished. In the pop up, you usually have "Open", "Execute" and "Cancel". But for *.exe, "Open" is actually to be executed by Wine? "Execute" will do nothing because it isn't a native executable for Linux/BSD.

guoyunhe updated this revision to Diff 67444.Oct 7 2019, 5:22 PM

"openAsExecute" parameter for ExecutableFileOpenDialog

guoyunhe retitled this revision from Treat "application/x-ms-dos-executable" as executable on all platforms to WIP: Treat "application/x-ms-dos-executable" as executable on all platforms.Oct 7 2019, 5:34 PM
guoyunhe edited the summary of this revision. (Show Details)
guoyunhe updated this revision to Diff 67458.Oct 7 2019, 8:30 PM

Fix *.exe execution condition

guoyunhe added a comment.EditedOct 7 2019, 8:41 PM

It is now working. The condition is so complex. Please help test this patch!

guoyunhe retitled this revision from WIP: Treat "application/x-ms-dos-executable" as executable on all platforms to Treat "application/x-ms-dos-executable" as executable on all platforms.Oct 7 2019, 9:11 PM
guoyunhe edited the summary of this revision. (Show Details)
guoyunhe edited the summary of this revision. (Show Details)Oct 7 2019, 9:16 PM
ppeter added a subscriber: ppeter.Oct 8 2019, 12:38 PM
ppeter added inline comments.
src/widgets/executablefileopendialog.cpp
58
if (mode == OnlyExecute)
  connect(executeButton, ...)
else if (mode == OpenAsExecute)
  ...

looks better :)

GB_2 added a subscriber: GB_2.Oct 8 2019, 12:46 PM
GB_2 added inline comments.
src/widgets/executablefileopendialog.cpp
58

That would be against the common KDE coding style: https://community.kde.org/Policies/Kdelibs_Coding_Style#Braces

dfaure requested changes to this revision.Oct 11 2019, 11:02 PM
dfaure added inline comments.
src/widgets/krun.cpp
1101

should this be in ifdef Q_OS_WIN?

On windows, *.exe is executed, not opened (with e.g. wine)

This revision now requires changes to proceed.Oct 11 2019, 11:02 PM
guoyunhe updated this revision to Diff 67761.Oct 12 2019, 7:15 AM

*.exe should be normal executable in Windows

guoyunhe marked an inline comment as done.Oct 12 2019, 7:16 AM
guoyunhe added inline comments.
src/widgets/krun.cpp
1101

Yes, I updated this part.

dfaure accepted this revision.Oct 15 2019, 6:21 AM
This revision is now accepted and ready to land.Oct 15 2019, 6:21 AM
This revision was automatically updated to reflect the committed changes.