After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 616645 - Renaming a file through Samba overwrites existing one
Renaming a file through Samba overwrites existing one
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: smb backend
unspecified
Other Linux
: Normal major
: ---
Assigned To: Tomas Bzatek
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2010-04-23 13:25 UTC by Brice Terzaghi
Modified: 2011-09-19 11:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch (2.19 KB, patch)
2011-08-29 16:25 UTC, Tomas Bzatek
committed Details | Review

Description Brice Terzaghi 2010-04-23 13:25:47 UTC
Using Ubuntu 9.10, filed a bug on Launchpad (https://bugs.launchpad.net/ubuntu/+source/samba/+bug/382117) but seems to be upstream bug.

When mounting a Samba share with Nautilus and renaming a file in it, it doesn't check if the name already exists and overwrites any existing one without warning.

I.e. I have two files "file1" and "file2" on my Samba share, I rename "file2" to "file1": the original "file1" is lost forever.

As specified in the Ubuntu bug report, the same behaviour happens with the mv command (both in local and through SSH) but not with a remote folder mounted through SSH with Nautilus.
Seems that the bug has been traced to gvfs by the Ubuntu developers (I originally filed it under Samba).
Comment 1 Michał Sawicz 2011-07-10 19:01:53 UTC
I can confirm this behavior for gvfs-1.8.2.
Comment 2 Tomas Bzatek 2011-08-15 16:01:01 UTC
Confirming, not nice. I guess we would have to do one more stat before real smbc_rename(). Interesting enough the libsmbclient documentation talks about EEXIST error that should be returned but it's not.
Comment 3 Tomas Bzatek 2011-08-29 16:25:12 UTC
Created attachment 195085 [details] [review]
proposed patch

Always stat the destination before doing rename. This brings one new string for translation, commit after upcoming tarball.

TODO: test overwrites on file copy/move
Comment 4 Tomas Bzatek 2011-08-30 15:44:03 UTC
commit 62d2a521df6a7adf8a1dc9598e81947a56c9f3b9
Author: Tomas Bzatek <tbzatek@redhat.com>
Date:   Tue Aug 30 17:43:09 2011 +0200

    smb: Always check for existing file on rename
    
    Libsmbclient reports no error when target file or directory
    exists and overwrites target file.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=616645
Comment 5 Vlad C. 2011-09-17 05:13:38 UTC
It would seem that the correct fix is to libsmbclient. Working around a SAMBA bug in GVFS is like putting a bandaid over an infected wound. Has anyone opened a bug report with SAMBA?

If in the future libsmbclient gets fixed to emit EEXIST, GNOME will be stuck doing redundant checks  that slow things down and lead to confusion. I therefore recommend reverting http://git.gnome.org/browse/gvfs/commit/?id=62d2a521df6a7adf8a1dc9598e81947a56c9f3b9 and pushing SAMBA to fix their bug.
Comment 6 Tomas Bzatek 2011-09-19 11:48:18 UTC
Yes, correct way would be to fix libsmbclient. With tons of other things that we have workarounds for. And then you would have to make gvfs dependent on that new version. From my experience many distributors are rather conservative in samba version and we would like to have Gnome running there, thus we should support older versions. Think of jhbuild for example.