diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | sftp-server.c | 24 |
2 files changed, 25 insertions, 5 deletions
@@ -14,6 +14,10 @@ | |||
14 | - djm@cvs.openbsd.org 2004/06/25 01:25:12 | 14 | - djm@cvs.openbsd.org 2004/06/25 01:25:12 |
15 | [regress/test-exec.sh] | 15 | [regress/test-exec.sh] |
16 | clean reexec-specific junk out of text-exec.sh and simplify; idea markus@ | 16 | clean reexec-specific junk out of text-exec.sh and simplify; idea markus@ |
17 | - dtucker@cvs.openbsd.org 2004/06/25 05:38:48 | ||
18 | [sftp-server.c] | ||
19 | Fall back to stat+rename if filesystem doesn't doesn't support hard | ||
20 | links. bz#823, ok djm@ | ||
17 | - (dtucker) [configure.ac openbsd-compat/misc.c [openbsd-compat/misc.h] | 21 | - (dtucker) [configure.ac openbsd-compat/misc.c [openbsd-compat/misc.h] |
18 | Add closefrom() for platforms that don't have it. | 22 | Add closefrom() for platforms that don't have it. |
19 | - (dtucker) [sshd.c] add line missing from reexec sync. | 23 | - (dtucker) [sshd.c] add line missing from reexec sync. |
@@ -1419,4 +1423,4 @@ | |||
1419 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM | 1423 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM |
1420 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu | 1424 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu |
1421 | 1425 | ||
1422 | $Id: ChangeLog,v 1.3449 2004/06/25 04:22:23 dtucker Exp $ | 1426 | $Id: ChangeLog,v 1.3450 2004/06/25 07:06:02 dtucker Exp $ |
diff --git a/sftp-server.c b/sftp-server.c index 8349c1763..39a6bdab4 100644 --- a/sftp-server.c +++ b/sftp-server.c | |||
@@ -14,7 +14,7 @@ | |||
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
15 | */ | 15 | */ |
16 | #include "includes.h" | 16 | #include "includes.h" |
17 | RCSID("$OpenBSD: sftp-server.c,v 1.46 2004/06/21 17:36:31 avsm Exp $"); | 17 | RCSID("$OpenBSD: sftp-server.c,v 1.47 2004/06/25 05:38:48 dtucker Exp $"); |
18 | 18 | ||
19 | #include "buffer.h" | 19 | #include "buffer.h" |
20 | #include "bufaux.h" | 20 | #include "bufaux.h" |
@@ -839,9 +839,25 @@ process_rename(void) | |||
839 | status = errno_to_portable(errno); | 839 | status = errno_to_portable(errno); |
840 | else if (S_ISREG(sb.st_mode)) { | 840 | else if (S_ISREG(sb.st_mode)) { |
841 | /* Race-free rename of regular files */ | 841 | /* Race-free rename of regular files */ |
842 | if (link(oldpath, newpath) == -1) | 842 | if (link(oldpath, newpath) == -1) { |
843 | status = errno_to_portable(errno); | 843 | if (errno == EOPNOTSUPP) { |
844 | else if (unlink(oldpath) == -1) { | 844 | struct stat st; |
845 | |||
846 | /* | ||
847 | * fs doesn't support links, so fall back to | ||
848 | * stat+rename. This is racy. | ||
849 | */ | ||
850 | if (stat(newpath, &st) == -1) { | ||
851 | if (rename(oldpath, newpath) == -1) | ||
852 | status = | ||
853 | errno_to_portable(errno); | ||
854 | else | ||
855 | status = SSH2_FX_OK; | ||
856 | } | ||
857 | } else { | ||
858 | status = errno_to_portable(errno); | ||
859 | } | ||
860 | } else if (unlink(oldpath) == -1) { | ||
845 | status = errno_to_portable(errno); | 861 | status = errno_to_portable(errno); |
846 | /* clean spare link */ | 862 | /* clean spare link */ |
847 | unlink(newpath); | 863 | unlink(newpath); |