sftp-server failing to rename a file

Christian Recktenwald openssh-contact at fischglas.de
Sun Feb 24 05:35:02 EST 2008


What to try:

	$ cd /tmp 
	$ touch a b
	$ sftp localhost
	sftp> cd /tmp
	sftp> rename a b
	Couldn't rename file "/tmp/a" to "/tmp/b": Failure
	sftp> rm b
	Removing /var/tmp/b
	sftp> rename a b
	sftp> 

So, the sftp "rename" command refuses to rename a file
to an existing one.

Instead of using the rename(2) system call, which is present at least on
SunOS 5.x, Linux 2.4 & 2.6, FreeBSD 4.x & 5.x and exists as of BSD4.3,
it uses link(2) which correctly refuses to overwrite an existing file.

This is not only confusing but prevents Linux' FUSE supported sshfs 
from working correctly. If a client application on the sshfs client
uses rename(2) - which is done by mv(1), ci(1) and other tools -
this issues a call to sftp's rename command which then failes 
due to the usage of link(2) instead of rename(2).

So I'd repectfully suggest to change the behaviour of sftp-server
in this case.

Best Regards, 
	Chris Recktenwald

-- 
Christian Recktenwald               |
openssh-contact at fischglas.de        |


More information about the openssh-unix-dev mailing list