Bug 345952

Summary: Krusader+kio_sftp: [data loss] Deleting symlink to directory recursively deletes linked directory
Product: [Applications] krusader Reporter: Kevin Kofler <kevin.kofler>
Component: generalAssignee: Krusader Bugs Distribution List <krusader-bugs-null>
Status: RESOLVED FIXED    
Severity: critical CC: davide, krusader-bugs-null, simon.persson
Priority: VHI    
Version First Reported In: 2.4.0-beta3 "Single Step"   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Kevin Kofler 2015-04-07 12:59:51 UTC
In Krusader, when operating on an sftp:// URL, deleting a symlink to a directory causes Krusader to recursively delete the linked directory. This is very unexpected and can lead to catastrophic data loss. I learned this the hard way, and with a less understanding employer, it could have cost me my job!

Reproducible: Always

Steps to Reproduce:
1. Connect to a sftp:// share.
2. Find a symlink to a nonempty directory (create one if needed).
3. Attempt to delete it from Krusader.

Actual Results:  
The linked directory gets emptied.

Expected Results:  
Only the symlink gets deleted.
Comment 1 Kevin Kofler 2015-04-07 13:20:09 UTC
More detailed steps to Reproduce:
1. Connect to a sftp:// share.
2. Create a directory named "test-bug345952-1".
3. Create a "test.txt" file inside "test-bug345952-1".
4. ssh into the server (creating a symlink from within Krusader is not offered over sftp).
5. ln -s test-bug345952-1 test-bug345952-2
6. Attempt to delete the directory "test-bug345952-2" from Krusader.

Not only does this delete the contents of "test-bug345952-1" (the "test.txt" file you created), but it also fails to delete the symlink, claiming no such directory exists. (So this deletes stuff I DIDN'T want to delete while NOT deleting the stuff I actually wanted to delete.) This failure is suprising because Krusader correctly displays the directory as a symlink.
Comment 2 Kevin Kofler 2015-04-07 13:23:26 UTC
Dolphin does the right thing, so this is not kio_sftp's fault.
Comment 3 Kevin Kofler 2015-04-07 16:22:42 UTC
This behavior cannot be observed on local files though. I redid the test on a local directory, and there, only the symlink was deleted, as expected.
Comment 4 Kevin Kofler 2015-05-15 10:49:52 UTC
Ping? Is anybody reading this? This is a major data loss bug, it must be addressed ASAP!
Comment 5 Kevin Kofler 2015-05-20 21:01:53 UTC
CCing Davide Gianforte, who is actively working on the KF5 port (though I haven't checked whether this bug can be reproduced there, I checked it only with the kdelibs4 version).
Comment 6 Simon Persson 2015-06-26 10:25:29 UTC
Tested this now and can confirm the bug in last  released version for KDE4.
Also found the bug present after straight porting to KF5/Qt5.
I fixed it in commit 5ad78473c10fd339f185c5584f6fd7f03acf73d2 in the plasma branch (but this commit really has nothing to do with porting), although I did not know about this bug then. Interesting that when digging through commit history, the change that introduced the problem mentions that it was a fix for following links on sftp... It's been like that since 2004. (It could of course be there was no bug back then but that KIO has changed behaviour since then)
Anyway, closing this as FIXED. Thanks for reporting! Indeed, quite an ugly one!