]> andersk Git - openssh.git/commitdiff
- dtucker@cvs.openbsd.org 2004/06/25 05:38:48
authordtucker <dtucker>
Fri, 25 Jun 2004 07:06:02 +0000 (07:06 +0000)
committerdtucker <dtucker>
Fri, 25 Jun 2004 07:06:02 +0000 (07:06 +0000)
     [sftp-server.c]
     Fall back to stat+rename if filesystem doesn't doesn't support hard
     links.  bz#823, ok djm@

ChangeLog
sftp-server.c

index c05dc36709c88f95e71b2c42beace04de862966c..160304fa6e307c4ba3901df97a7a4c331f3136c4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
    - djm@cvs.openbsd.org 2004/06/25 01:25:12
      [regress/test-exec.sh]
      clean reexec-specific junk out of text-exec.sh and simplify; idea markus@
+   - 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@
  - (dtucker) [configure.ac openbsd-compat/misc.c [openbsd-compat/misc.h]
    Add closefrom() for platforms that don't have it.
  - (dtucker) [sshd.c] add line missing from reexec sync.
index 8349c176396d7f3441e499e555fc7e254ea057c0..39a6bdab4e092a3e9897c9445e25e3e1125c5e53 100644 (file)
@@ -14,7 +14,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 #include "includes.h"
-RCSID("$OpenBSD: sftp-server.c,v 1.46 2004/06/21 17:36:31 avsm Exp $");
+RCSID("$OpenBSD: sftp-server.c,v 1.47 2004/06/25 05:38:48 dtucker Exp $");
 
 #include "buffer.h"
 #include "bufaux.h"
@@ -839,9 +839,25 @@ process_rename(void)
                status = errno_to_portable(errno);
        else if (S_ISREG(sb.st_mode)) {
                /* Race-free rename of regular files */
-               if (link(oldpath, newpath) == -1)
-                       status = errno_to_portable(errno);
-               else if (unlink(oldpath) == -1) {
+               if (link(oldpath, newpath) == -1) {
+                       if (errno == EOPNOTSUPP) {
+                               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);
This page took 0.078268 seconds and 5 git commands to generate.