SUMMARY A symlink to a text file (both located in a folder accessed via SFTP) only shows a truncated version of that text file when accessed through SFTP. STEPS TO REPRODUCE 1. On a remote computer (which you have ssh access to), make a symlink to a long text file (size needs to be more than a few bytes; I used a 1.7KB text file as an example) 2. Open the symlink location in Dolphin on your local computer (In the address bar, type sftp://USERNAME@SERVER:22/PATH_TO_FILE/ ) 3. Open the symlink with Kate 4. Copy the symlink to a local folder using Dolphin OBSERVED RESULTS 3. Kate only shows the first few characters of the file. 4. The local copy created by Dolphin only contains the first few characters of the file. EXPECTED RESULTS 3. Kate should show the entire file 4. Dolphin should copy the entire file SOFTWARE VERSIONS kate 24.08.3 kio-extras 24.08.3 libssh 0.11.1 libssh2 1.11.0 openssh 9.9p1 sshfs 3.7.3 Operating System: Arch Linux KDE Plasma Version: 6.2.4 KDE Frameworks Version: 6.8.0 Qt Version: 6.8.1 Kernel Version: 6.12.3-arch1-1 (64-bit) ADDITIONAL INFORMATION A. If I do the same on a local filesystem, the entire file is shown when opening the symlink. B. Permissions in a case where this bug can be reproduced (I opened link.txt, which I earlier created using `ln -s`) ``` $ ls -lh total 4.0K lrwxrwxrwx 1 ckishore expert 13 Dec 8 15:20 link.txt -> test_file.txt -rw-r--r-- 1 ckishore expert 1.8K Dec 8 15:20 test_file.txt ``` C. Note that the size of the symlink is 13B; in this case, exactly the first 13 characters of the text file were shown, suggesting that kio_sftp is wrongly truncating the file based on the symlink size. D. On the remote computer, using `cat link.txt` gives me the entire text file, suggesting there is no issue on the remote end.
Hi - thanks for the detailed report! I'm unable to reproduce it on my system below, though - has this situation ever worked correctly on your system (if you had ever tried it before?), even if under previous software versions? Operating System: Fedora Linux 41 KDE Plasma Version: 6.2.4 KDE Frameworks Version: 6.9.0 Qt Version: 6.8.1 Kernel Version: 6.12.4-200.fc41.x86_64 (64-bit)
(In reply to John Kizer from comment #1) > Hi - thanks for the detailed report! I'm unable to reproduce it on my system > below, though - has this situation ever worked correctly on your system (if > you had ever tried it before?), even if under previous software versions? > > Operating System: Fedora Linux 41 > KDE Plasma Version: 6.2.4 > KDE Frameworks Version: 6.9.0 > Qt Version: 6.8.1 > Kernel Version: 6.12.4-200.fc41.x86_64 (64-bit) It used to work correctly on my system. Unfortunately, I'm not sure exactly how long ago it stopped working, since I don't access symlinks on remote systems that often. Fedora 41 has libssh 0.10.6, while I have 0.11.1 on Arch Linux. I suspect this could be related to the new feature mentioned in https://bugs.kde.org/show_bug.cgi?id=296526#c42 . One way to confirm this would be for me to build a version of kio-sftp with that feature patched out, but that will have to wait until the weekend at least.
(In reply to Kishore Gopalakrishnan from comment #2) > [snip] > > Fedora 41 has libssh 0.10.6, while I have 0.11.1 on Arch Linux. I suspect > this could be related to the new feature mentioned in > https://bugs.kde.org/show_bug.cgi?id=296526#c42 . > > [snip] I have confirmed this. The bug is not reproducible if I remove the `HAVE_SFTP_AIO` option from kio-extras/sftp/CMakeLists.txt (forcing kio-sftp to always use the old code path).
The issue is fixed by replacing all uses of `sftp_lstat` by `sftp_stat` in kio_sftp.cpp
A possibly relevant merge request was started @ https://invent.kde.org/network/kio-extras/-/merge_requests/403
Git commit 5fd0630699e5d0d150709bf0cd5e935d725137f0 by Méven Car, on behalf of Kishore Gopalakrishnan. Committed on 23/02/2025 at 10:07. Pushed by meven into branch 'master'. sftp: use stat instead of lstat Using lstat leads to symlinks being truncated (since the file gets truncated according to the size of the symlink, and not the size of the target file). open and sftpGet now use sftp_stat, while the remaining methods (sftpPut, stat, mkdir, rename, symlink) still use sftp_lstat. M +4 -2 sftp/kio_sftp.cpp https://invent.kde.org/network/kio-extras/-/commit/5fd0630699e5d0d150709bf0cd5e935d725137f0
*** Bug 501701 has been marked as a duplicate of this bug. ***