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 |
Christian Recktenwald wrote: [...]> So, the sftp "rename" command refuses to rename a file > to an existing one.This behaviour is mandated by the version of the filexfer draft that OpenSSH implements [1]. About SSH_FXP_RENAME, section 6.5 says: "It is an error if there already exists a file with the name specified by newpath." [1] http://www.openssh.com/txt/draft-ietf-secsh-filexfer-02.txt, which somewhat confusingly defines version 3 of the protocol. -- Darren Tucker (dtucker at zip.com.au) GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4 37C9 C982 80C7 8FF4 FA69 Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.
On Sun, 24 Feb 2008, Darren Tucker wrote:> Christian Recktenwald wrote: > [...] > > So, the sftp "rename" command refuses to rename a file > > to an existing one. > > This behaviour is mandated by the version of the filexfer draft that > OpenSSH implements [1]. About SSH_FXP_RENAME, section 6.5 says: > > "It is an error if there already exists a file > with the name specified by newpath." > > [1] http://www.openssh.com/txt/draft-ietf-secsh-filexfer-02.txt, > which somewhat confusingly defines version 3 of the protocol.There is an open enhancement request to add this at: https://bugzilla.mindrot.org/show_bug.cgi?id=1400 -d
On Sun, Feb 24, 2008 at 10:55:30AM +1100, Darren Tucker wrote:> Christian Recktenwald wrote: > [...] > >So, the sftp "rename" command refuses to rename a file > >to an existing one. > > This behaviour is mandated by the version of the filexfer draft that > OpenSSH implements [1]. About SSH_FXP_RENAME, section 6.5 says: > > "It is an error if there already exists a file > with the name specified by newpath."Yeah sure. But it would be of great benefit to change this. And as it is an (outdated) draft, you may take this as a suggestion to change it also :-) -- Christian Recktenwald | elwood sys adm openssh-contact at fischglas.de |