summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--sftp-client.c24
2 files changed, 27 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 985e8050d..73760b809 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,14 @@
18 Repair the simple cases for msg_controllen where it should just be 18 Repair the simple cases for msg_controllen where it should just be
19 CMSG_SIZE(sizeof(int)), not sizeof(buffer) which may be larger because 19 CMSG_SIZE(sizeof(int)), not sizeof(buffer) which may be larger because
20 of alignment; ok kettenis hshoexer 20 of alignment; ok kettenis hshoexer
21 - djm@cvs.openbsd.org 2008/03/23 12:54:01
22 [sftp-client.c]
23 prefer POSIX-style file renaming over filexfer rename behaviour if the
24 server supports the posix-rename@openssh.com extension.
25 Note that the old (filexfer) behaviour would refuse to clobber an
26 existing file. Users who depended on this should adjust their sftp(1)
27 usage.
28 ok deraadt@ markus@
21 29
2220080315 3020080315
23 - (djm) [regress/test-exec.sh] Quote putty-related variables in case they are 31 - (djm) [regress/test-exec.sh] Quote putty-related variables in case they are
@@ -3786,4 +3794,4 @@
3786 OpenServer 6 and add osr5bigcrypt support so when someone migrates 3794 OpenServer 6 and add osr5bigcrypt support so when someone migrates
3787 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 3795 passwords between UnixWare and OpenServer they will still work. OK dtucker@
3788 3796
3789$Id: ChangeLog,v 1.4884 2008/03/26 23:54:44 djm Exp $ 3797$Id: ChangeLog,v 1.4885 2008/03/26 23:59:57 djm Exp $
diff --git a/sftp-client.c b/sftp-client.c
index b189422d4..69c637785 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-client.c,v 1.80 2008/01/21 19:20:17 djm Exp $ */ 1/* $OpenBSD: sftp-client.c,v 1.81 2008/03/23 12:54:01 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -65,6 +65,8 @@ struct sftp_conn {
65 u_int num_requests; 65 u_int num_requests;
66 u_int version; 66 u_int version;
67 u_int msg_id; 67 u_int msg_id;
68#define SFTP_EXT_POSIX_RENAME 1
69 u_int exts;
68}; 70};
69 71
70static void 72static void
@@ -239,7 +241,7 @@ get_decode_stat(int fd, u_int expected_id, int quiet)
239struct sftp_conn * 241struct sftp_conn *
240do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests) 242do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests)
241{ 243{
242 u_int type; 244 u_int type, exts = 0;
243 int version; 245 int version;
244 Buffer msg; 246 Buffer msg;
245 struct sftp_conn *ret; 247 struct sftp_conn *ret;
@@ -270,6 +272,8 @@ do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests)
270 char *value = buffer_get_string(&msg, NULL); 272 char *value = buffer_get_string(&msg, NULL);
271 273
272 debug2("Init extension: \"%s\"", name); 274 debug2("Init extension: \"%s\"", name);
275 if (strcmp(name, "posix-rename@openssh.com") == 0)
276 exts |= SFTP_EXT_POSIX_RENAME;
273 xfree(name); 277 xfree(name);
274 xfree(value); 278 xfree(value);
275 } 279 }
@@ -283,6 +287,7 @@ do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests)
283 ret->num_requests = num_requests; 287 ret->num_requests = num_requests;
284 ret->version = version; 288 ret->version = version;
285 ret->msg_id = 1; 289 ret->msg_id = 1;
290 ret->exts = exts;
286 291
287 /* Some filexfer v.0 servers don't support large packets */ 292 /* Some filexfer v.0 servers don't support large packets */
288 if (version == 0) 293 if (version == 0)
@@ -639,13 +644,20 @@ do_rename(struct sftp_conn *conn, char *oldpath, char *newpath)
639 644
640 /* Send rename request */ 645 /* Send rename request */
641 id = conn->msg_id++; 646 id = conn->msg_id++;
642 buffer_put_char(&msg, SSH2_FXP_RENAME); 647 if ((conn->exts & SFTP_EXT_POSIX_RENAME)) {
643 buffer_put_int(&msg, id); 648 buffer_put_char(&msg, SSH2_FXP_EXTENDED);
649 buffer_put_int(&msg, id);
650 buffer_put_cstring(&msg, "posix-rename@openssh.com");
651 } else {
652 buffer_put_char(&msg, SSH2_FXP_RENAME);
653 buffer_put_int(&msg, id);
654 }
644 buffer_put_cstring(&msg, oldpath); 655 buffer_put_cstring(&msg, oldpath);
645 buffer_put_cstring(&msg, newpath); 656 buffer_put_cstring(&msg, newpath);
646 send_msg(conn->fd_out, &msg); 657 send_msg(conn->fd_out, &msg);
647 debug3("Sent message SSH2_FXP_RENAME \"%s\" -> \"%s\"", oldpath, 658 debug3("Sent message %s \"%s\" -> \"%s\"",
648 newpath); 659 (conn->exts & SFTP_EXT_POSIX_RENAME) ? "posix-rename@openssh.com" :
660 "SSH2_FXP_RENAME", oldpath, newpath);
649 buffer_free(&msg); 661 buffer_free(&msg);
650 662
651 status = get_status(conn->fd_in, id); 663 status = get_status(conn->fd_in, id);