[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#352589: closed by Colin Watson <cjwatson@debian.org> (Bug#308561: fixed in openssh 1:5.1p1-1)



On Fri, Jul 25, 2008 at 01:17:31PM +0100, Richard Kettlewell wrote:
> Debian Bug Tracking System wrote:
> >This is an automatic notification regarding your Bug report
> >which was filed against the openssh package:
> >
> >#308561: openssh sftp-server can't SSH_FXP_RENAME on FAT32
> >
> >It has been closed by Colin Watson <cjwatson@debian.org>.
> 
> The text from the upload notice is:
>        + Added a protocol extension method "posix-rename@openssh.com"
>          for sftp-server(8) to perform POSIX atomic rename()
>          operations; sftp(1) prefers this if available (closes:
>          #308561).
> 
> I don't really agree that this actually fixes #352589.  It does make it 
> possible to rename using sftp(1) but it does not change the behaviour of 
> the lower-level operation SSH_FXP_RENAME, which was what my report was 
> about.

I wasn't clear in the changelog, but in fact your bug is dealt with
directly as well. The new code looks like this:

                /* Race-free rename of regular files */
                if (link(oldpath, newpath) == -1) {
                        if (errno == EOPNOTSUPP
#ifdef EXDEV
                            || errno == EXDEV
#endif
#ifdef LINK_OPNOTSUPP_ERRNO
                            || errno == LINK_OPNOTSUPP_ERRNO
#endif
                            ) {
                                struct stat st;

                                /*
                                 * fs doesn't support links, so fall back to
                                 * stat+rename.  This is racy.
                                 */
                                if (stat(newpath, &st) == -1) {
                                        if (rename(oldpath, newpath) == -1)
                                                status =
                                                    errno_to_portable(errno);
                                        else
                                                status = SSH2_FX_OK;
                                }
                        } else {
                                status = errno_to_portable(errno);
                        }
                } else if (unlink(oldpath) == -1) {
                        status = errno_to_portable(errno);
                        /* clean spare link */
                        unlink(newpath);
                } else
                        status = SSH2_FX_OK;

configure defines LINK_OPNOTSUPP_ERRNO to EPERM on Linux.

It looks as if this was in fact fixed quite some time ago. From the CVS
log for sftp-server.c:

revision 1.54
date: 2004/06/25 07:06:03;  author: dtucker;  state: Exp;  lines: +20 -4
   - dtucker@cvs.openbsd.org 2004/06/25 05:38:48
     [sftp-server.c]
     Fall back to stat+rename if filesystem doesn't doesn't support hard
     links.  bz#823, ok djm@
revision 1.55
date: 2004/06/28 06:01:20;  author: dtucker;  state: Exp;  lines: +5 -1
 - (dtucker) [acconfig.h configure.ac sftp-server.c] Bug #823: add sftp
   rename handling for Linux which returns EPERM for link() on (at least some)
   filesystems that do not support hard links.  sftp-server will fall back to
   stat+rename() in such cases.

That would correspond to OpenSSH 3.9p1.
https://bugzilla.mindrot.org/show_bug.cgi?id=823 is the upstream bug.
Sorry I didn't notice this before.

-- 
Colin Watson                                       [cjwatson@debian.org]



Reply to: