Bug 436708 - MimeTypeFinderJob does not follow symlinks - causes problem launching file manager
Summary: MimeTypeFinderJob does not follow symlinks - causes problem launching file ma...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-06 20:33 UTC by Jonathan Marten
Modified: 2021-05-27 19:26 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.83
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Marten 2021-05-06 20:33:45 UTC
SUMMARY

This can be demonstarted by trying to open a directory, either directly or via a Type=Link desktop file, which refers to a symbolic link.  The link is not followed which means that an incorrect (or no) MIME type is returned.  This happens when launching such a desktop file from the Plasma desktop, but it can be reproduced from the command line.

STEPS TO REPRODUCE

1. Set up test directories/symlinks as follows:

drwxr-xr-x 2 user users 40 May  6 20:46 /tmp/a/
lrwxrwxrwx 1 user users  1 May  6 20:46 /tmp/b -> a/

2. Execute 'kioclient5 exec file:///tmp/a'

==> The directory /tmp/a is opened in the default file manager

3. Execute 'kioclient5 exec file:///tmp/b'

==> No file manager is started
    An error box saying simply "/tmp/b" is displayed
    A debug message is shown:

kioclient KIO::MimeTypeFinderJobPrivate::scanFileWithGet()::<lambda: KIO::get didn't emit a mimetype! Please fix the ioslave for URL QUrl("file:///tmp/b")

OBSERVED RESULT

Failure as in (3) above

EXPECTED RESULT

In (3) above the directory /tmp/b should be opened in the default file manager.

SOFTWARE/OS VERSIONS

Operating System: Gentoo
KDE Plasma Version: 5.21.80
KDE Frameworks Version: 5.82.0
Qt Version: 5.15.2
Kernel Version: 5.10.27-gentoo-x86_64 (64-bit)
Graphics Platform: X11

ADDITIONAL INFORMATION

These desktop files, if placed on the Plasma desktop, will give the same results when launched.

ok.desktop:

[Desktop Entry]
Type=Link
URL[$e]=file:///tmp/a

fail.desktop:

[Desktop Entry]
Type=Link
URL[$e]=file:///tmp/b
Comment 1 Jonathan Marten 2021-05-06 20:41:36 UTC
Replacing the KIO::StatBasic near the start of KIO::MimeTypeFinderJobPrivate::statFile() with
KIO::StatBasic||KIO::StatResolveSymlink
fixes the problem, but I don't know if there are other implications if doing this.
Comment 2 Nate Graham 2021-05-07 19:38:43 UTC
Might make sense to open a merge request and ask again in there.
Comment 3 Bug Janitor Service 2021-05-07 20:20:35 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/442