Bug 507278 - Can not access remote root directory (/) via SFTP
Summary: Can not access remote root directory (/) via SFTP
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: 6.16.0
Platform: Arch Linux Linux
: HI normal
Target Milestone: ---
Assignee: KIO Bugs
URL: https://invent.kde.org/frameworks/kio...
Keywords: regression
: 507450 507922 (view as bug list)
Depends on:
Blocks:
 
Reported: 2025-07-20 16:29 UTC by Hanabishi
Modified: 2025-08-07 07:38 UTC (History)
5 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hanabishi 2025-07-20 16:29:54 UTC
SUMMARY

KIO 6.16.0 has broke ability to access remote root (/) directory via SFTP. User's home dir is always shown instead.

STEPS TO REPRODUCE
1. Connect to any SFTP server via Dolphin and navigate to the root directory, e.g. 'sftp://user@server//'.

OBSERVED RESULT

User's home dir always shown instead of /.

EXPECTED RESULT

/ should be accessible.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
KDE Plasma Version: 6.4.3
KDE Frameworks Version: 6.16.0
Qt Version: 6.9.1

ADDITIONAL INFORMATION

I performed bisection and found the offending commit:

commit 883a16eb4ac808deceddf8ac3667ee888ff8ea60 (HEAD)
Author: Akseli Lahtinen <akselmo@akselmo.dev>
Date:   Wed Jun 25 13:23:07 2025 +0300

    KCoreDirLister: Clean up the trailing slash as expected on remote systems
    
    Due to QTBUG-35921 we sometimes get a trailing slash even if we expect
    it to be removed.
    This patch adds a method that makes sure the trailing slash is
    completely removed from the URL
    and returns the cleaned URL, but only if the file is in remote directoy.
    
    The code was built around the behavior of the trailing
    slash always being removed, so it was comparing URLs:
    Even if the URLs point to same location, `smb://aaa` and `smb://aaa/`,
    the URLs are considered as different ones.
    
    On remote systems we do not know if the file system allows `foo/bar` and
    `foo/bar/` to be the exact same or not. On local systems we can rely on
    Qt.
    
    This fixes bug that would cause situations where the job is reusing
    itself for the two "different" URLs (from the point of view of the code)
    and asserting, as every different URL should have a new job.
    
    BUG: 451050

 src/core/kcoredirlister.cpp | 70 ++++++++++++++++++++++++++++++++++++++++++----------------------------
 src/core/kcoredirlister_p.h | 10 ++++++++++
 2 files changed, 52 insertions(+), 28 deletions(-)

Introduced in https://invent.kde.org/frameworks/kio/-/merge_requests/1921
Comment 1 Bug Janitor Service 2025-07-21 12:49:40 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1940
Comment 2 Antonio Rojas 2025-07-24 16:23:08 UTC
*** Bug 507450 has been marked as a duplicate of this bug. ***
Comment 3 Akseli Lahtinen 2025-07-28 10:07:32 UTC
Git commit 2cf5289d9e994f830749eb30791aabe1719406f9 by Akseli Lahtinen.
Committed on 28/07/2025 at 09:45.
Pushed by akselmo into branch 'master'.

KCoreDirLister: Do not list files again if the new url has same job

When getting a redirection URL, we check if the URL already has a job or
not. We also check that it's not the current job we're working on.

If it has same job as given to the slot as parameter, we are not
working on a new directory, but an old one. This can happen
when we are in `sftp://foo@bar/home/foo`, then type `sftp://foo@bar`
which in turn redirects us back to `sftp://foo@bar/home/foo`.

In these cases, we know we're not working on a new directory,
so we handle it through cache or refreshing it.

This fixes crashes with the oldJob assert and also
gives back to Qt the trailing slash handling, while
keeping expected behavior.

This also implements the mock test of commit 0808afd7
Related: bug 451050, bug 507185

M  +4    -0    CMakeLists.txt
M  +70   -8    autotests/kdirlistertest.cpp
M  +3    -2    autotests/kdirlistertest.h
M  +9    -15   src/core/kcoredirlister.cpp
M  +4    -0    src/core/worker.cpp
M  +4    -0    src/core/worker_p.h

https://invent.kde.org/frameworks/kio/-/commit/2cf5289d9e994f830749eb30791aabe1719406f9
Comment 4 Méven 2025-08-07 07:38:38 UTC
*** Bug 507922 has been marked as a duplicate of this bug. ***