Renaming a file through Samba overwrites existing one

Bug #382117 reported by Brice Terzaghi
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
samba
Fix Released
High
gvfs (Ubuntu)
Triaged
Low
Unassigned
samba (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: samba

Using Ubuntu "Jaunty" 9.04 with Samba 2:3.3.2-1ubuntu3.

I have a local server with directories shared through Samba and access them from another computer using Nautilus. When renaming a file to a name that already exists in the current dir, the original file is replaced without warning instead of having an error message like "can't rename: file already exists".
E.g.:
- access a Samba share through Nautilus
- create two blank files (blank_file_1 & blank_file_2)
- rename blank_file_2 to "blank_file_1"
- blank_file_1 is lost forever and now replaced by the content of blank_file_2

The problem doesn't happen with a remote directory mounted as sftp (error message saying that the file already exists) but does happen with the "mv" command in command line (in local dir or through ssh) so I'm not sure if the problem is related to Samba or mv or both.
Is mv supposed to overwrite existing files without warning or errors ?

Revision history for this message
Thierry Carrez (ttx) wrote :

Yes, it's normal behavior for mv to overwrite without warning in this case. Use "mv -i" to prompt on overwrite.
I'd say it's a bug in Nautilus, if any. Probably linked to bug 316653.

Revision history for this message
Thierry Carrez (ttx) wrote :

Marking Samba as invalid as smbclient delivers expected behavior, please reopen if you can point to a specific bug/missingfeature in Samba.

Changed in samba (Ubuntu):
status: New → Invalid
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. Please answer these questions:

 * Is this reproducible?
 * If so, what specific steps should we take to recreate this bug?
 * How do you mount the share? is that specific to nautilus?

 This will help us to find and resolve the problem.

Changed in nautilus (Ubuntu):
assignee: nobody → Ubuntu Desktop Bugs (desktop-bugs)
importance: Undecided → Low
status: New → Incomplete
Revision history for this message
Brice Terzaghi (terzag) wrote :

It is fully reproductible with the steps I've descriped above.

I mount the share from the "Shortcuts" menu (not sure of the english name : it's the GNOME menu with shortcuts to usual places, recent documents, etc. between "Applications" and "System" ; it's called "Raccourcis" in french, maybe it's called "Places" in english). I use "connect to server" then choose "Windows share", set the host name, user name and the Samba share appears on the desktop. I then browse through it with Nautilus.

The server runs Ubuntu too, Samba shares have been set on it remotely via Webmin (I'm not connecting to a Windows system).

How can I check if the problem exists without Nautilus ? Are there commands I can type in a terminal to connect to a Samba share and manage files on it ?

Revision history for this message
Mathias Gug (mathiaz) wrote : Re: [Bug 382117] Re: Renaming a file through Samba overwrites existing one

On Mon, Jun 22, 2009 at 02:49:41PM -0000, Brice Terzaghi wrote:
> The server runs Ubuntu too, Samba shares have been set on it remotely
> via Webmin (I'm not connecting to a Windows system).

Could you post the remove server configuration (/etc/samba/smb.conf)?

> How can I check if the problem exists without Nautilus ? Are there
> commands I can type in a terminal to connect to a Samba share and manage
> files on it ?

You can run the following commands from a terminal:

To test:

 1. install the samba-client package
 2. try to connect to the remote system from the command line:

    smbclient //remote_system/share_name

If the share requires a specific username/password, try using the "-U"
parameter (for example, use "-U ntdomain\\user").

--
Mathias Gug
Ubuntu Developer http://www.ubuntu.com

Revision history for this message
Brice Terzaghi (terzag) wrote :
Download full text (11.3 KiB)

When connected to a Samba share with smbclient, do I use the usual commands (cp, mv...) or are there commands specific to Samba ?

Here is my smb.conf :
----------------------------------------------------------------------
[global]
 log file = /var/log/samba/log.%m
 passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
 obey pam restrictions = yes
 map to guest = bad user
 encrypt passwords = true
 passwd program = /usr/bin/passwd %u
 passdb backend = tdbsam
 dns proxy = no
 writeable = yes
 server string = %h server (Samba, Ubuntu)
 unix password sync = yes
 workgroup = WORKGROUP
 syslog = 0
 panic action = /usr/share/samba/panic-action %d
 usershare allow guests = yes
 max log size = 1000
 pam password change = yes

## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of

# server string is the equivalent of the NT Description field

# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable its WINS Server
# wins support = no

# WINS Server - Tells the NMBD components of Samba to be a WINS Client
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
; wins server = w.x.y.z

# This will prevent nmbd to search for NetBIOS names through DNS.

# What naming service and in what order should we use to resolve host names
# to IP addresses
; name resolve order = lmhosts host wins bcast

#### Networking ####

# The specific set of interfaces / networks to bind to
# This can be either the interface name or an IP address/netmask;
# interface names are normally preferred
; interfaces = 127.0.0.0/8 eth0

# Only bind to the named interfaces and/or networks; you must use the
# 'interfaces' option above to use this.
# It is recommended that you enable this feature if your Samba machine is
# not protected by a firewall or is a firewall itself. However, this
# option cannot handle dynamic or non-broadcast interfaces correctly.
; bind interfaces only = yes

#### Debugging/Accounting ####

# This tells Samba to use a separate log file for each machine
# that connects

# Cap the size of the individual log files (in KiB).

# If you want Samba to only log through syslog then set the following
# parameter to 'yes'.
# syslog only = no

# We want Samba to log a minimum amount of information to syslog. Everything
# should go to /var/log/samba/log.{smbd,nmbd} instead. If you want to log
# through syslog you should set the following parameter to something higher.

# Do something sensible when Samba crashes: mail the admin a backtrace

####### Authentication #######

# "security = user" is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
# in the samba-doc package for details.
# security = user

# You may wish to use password encryption. See the section on
# 'encrypt passwords' in the smb.conf(5) manpage before enabling.

# If you are using encrypted passwords, Samba will need to know what
# password database type you are using.

# This boo...

Revision history for this message
Thierry Carrez (ttx) wrote :

smbclient uses FTP-like commands like ls / put / get
Please see http://manpages.ubuntu.com/manpages/jaunty/en/man1/smbclient.1.html#toptoc4

Revision history for this message
Brice Terzaghi (terzag) wrote :

Using smbclient, I tried to rename a dummy file to an existing name using the "rename" command. Got an error message saying the file already existed.
So I guess the problem comes from Nautilus not using the smbclient commands ?

Revision history for this message
Sebastien Bacher (seb128) wrote :

could you try if that's still an issue in karmic or lucid?

Revision history for this message
Brice Terzaghi (terzag) wrote :

Don't know for Lucid but the problem is still there in Karmic (packages up to date, with backports repository active).

Revision history for this message
Sebastien Bacher (seb128) wrote :

The issue is an upstream one and it would be nice if somebody having it could send the bug the to the people writting the software (https://wiki.ubuntu.com/Bugs/Upstream/GNOME)

affects: nautilus (Ubuntu) → gvfs (Ubuntu)
Changed in gvfs (Ubuntu):
assignee: Ubuntu Desktop Bugs (desktop-bugs) → nobody
status: Incomplete → New
Revision history for this message
Brice Terzaghi (terzag) wrote :
Changed in gvfs (Ubuntu):
status: New → Triaged
Changed in samba:
status: Unknown → New
Revision history for this message
Dan Andreșan (danyer) wrote :

Sebastien,

The bug still exists in Lucid (fully up to date).
I hit it by mistake, renaming some TV episodes on a NAS connected through Nautilus Samba (smb://server/share).
But, as you correctly pointed out, it is not related to samba, but to gvfs.

Allow me to be brief:
D1. create two files on desktop, one first.txt, second second.txt and write "first" in the first one and "second" in the second one
D2. try to rename first.txt to second.txt. Nautilus complains: 'The item could not be renamed. The name "second.txt" is already used in this folder. Please use a different name'. GOOD!

F1. copy first.txt and second.txt to a ftp server via Nautilus FTP connection.
F2. try to rename first.txt to second.txt. BAM! You've just lost the original second.txt

S1. copy first.txt and second.txt to a samba server via Nautilus SMB connection.
S2. try to rename first.txt to second.txt. BAM! You've just lost the original second.txt

This should not happen. Of course, Thierry is right, mv does not prompt. In this case, please remove the prompt from Nautilus in D2 case (on the desktop). Oh, the developer intent was to protect the user. In this case, protect the user also when he/she is using smb or ftp in Nautilus through gvfs.

Thanks,
Dan.

Changed in samba:
importance: Unknown → High
Changed in samba:
status: New → In Progress
Changed in samba:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.