Bug 251417 - editing files deletes them, destroying hardlinks
Summary: editing files deletes them, destroying hardlinks
Status: RESOLVED UPSTREAM
Alias: None
Product: kio-extras
Classification: Frameworks and Libraries
Component: SFTP (other bugs)
Version First Reported In: 18.04.3
Platform: openSUSE Linux
: NOR major
Target Milestone: ---
Assignee: Andreas Schneider
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-16 09:36 UTC by H.H.
Modified: 2020-03-04 15:06 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.H. 2010-09-16 09:36:15 UTC
Version:           0.1 (using KDE 4.5.1) 
OS:                Linux

This is really a severe bug, because it has bad side-effects on hardlinks:

1) open a file with multiple hardlinks directly via kio_sftp in kwrite
2) modify the file
3) save file

--> the original hardlink is deleted and a new file is created

The kio_fish-protocol behaves like expected (not deleting the hardlink)

Reproducible: Always




OS: Linux (x86_64) release 2.6.27.25-0.1-default
Compiler: gcc
Comment 1 Andreas Schneider 2010-09-16 11:15:49 UTC
Thank you for taking the time to report this bug and helping to make KDE better.

The kio_sftp slaves tries to do an atomic copy to prevent data loss.

If you copy a file to the server, it creates a temporary file. All data is written into this file and if it was successful the original file gets overwritten. This means that the hardlink gets overwritten in your case.

As the sftp protocol has never been finished there is no way to determine if a file is a hardlink or not. Only symlinks are supported and only with a trick on openssh.
Comment 2 H.H. 2010-09-16 19:29:54 UTC
how does fish do that? I have seen multiple google-results for "sftp hardlinks", there seem to exist some patches, but I don't know if and where they are integrated.
Comment 3 Andreas Schneider 2010-09-17 01:14:21 UTC
The sftp rename implementation is not a POSIX rename. Maybe a POSIX rename does it correctly.

OpenSSH has an sftp extension for a posix-rename. I could implement that and enable it for OpenSSH servers then.
Comment 4 H.H. 2018-07-20 21:47:20 UTC
That would be great. Here is the bug-report in openssh, and proof that openssh-5.7 supports hardlinks:

https://bugzilla.mindrot.org/show_bug.cgi?id=1555

Comment 8:
hard link patch is submitted and will be released in OpenSSH 5.7
Comment 5 Andreas Schneider 2018-09-03 05:59:27 UTC
I've opened https://bugs.libssh.org/T98
Comment 6 Harald Sitter 2020-03-04 15:06:48 UTC
Closing as this needs dealing with in libssh upstream.