- djm@cvs.openbsd.org 2008/03/23 12:54:01
[sftp-client.c] prefer POSIX-style file renaming over filexfer rename behaviour if the server supports the posix-rename@openssh.com extension. Note that the old (filexfer) behaviour would refuse to clobber an existing file. Users who depended on this should adjust their sftp(1) usage. ok deraadt@ markus@
This commit is contained in:
parent
be71e2d972
commit
7a3e1d0bc9
10
ChangeLog
10
ChangeLog
|
@ -18,6 +18,14 @@
|
||||||
Repair the simple cases for msg_controllen where it should just be
|
Repair the simple cases for msg_controllen where it should just be
|
||||||
CMSG_SIZE(sizeof(int)), not sizeof(buffer) which may be larger because
|
CMSG_SIZE(sizeof(int)), not sizeof(buffer) which may be larger because
|
||||||
of alignment; ok kettenis hshoexer
|
of alignment; ok kettenis hshoexer
|
||||||
|
- djm@cvs.openbsd.org 2008/03/23 12:54:01
|
||||||
|
[sftp-client.c]
|
||||||
|
prefer POSIX-style file renaming over filexfer rename behaviour if the
|
||||||
|
server supports the posix-rename@openssh.com extension.
|
||||||
|
Note that the old (filexfer) behaviour would refuse to clobber an
|
||||||
|
existing file. Users who depended on this should adjust their sftp(1)
|
||||||
|
usage.
|
||||||
|
ok deraadt@ markus@
|
||||||
|
|
||||||
20080315
|
20080315
|
||||||
- (djm) [regress/test-exec.sh] Quote putty-related variables in case they are
|
- (djm) [regress/test-exec.sh] Quote putty-related variables in case they are
|
||||||
|
@ -3786,4 +3794,4 @@
|
||||||
OpenServer 6 and add osr5bigcrypt support so when someone migrates
|
OpenServer 6 and add osr5bigcrypt support so when someone migrates
|
||||||
passwords between UnixWare and OpenServer they will still work. OK dtucker@
|
passwords between UnixWare and OpenServer they will still work. OK dtucker@
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.4884 2008/03/26 23:54:44 djm Exp $
|
$Id: ChangeLog,v 1.4885 2008/03/26 23:59:57 djm Exp $
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: sftp-client.c,v 1.80 2008/01/21 19:20:17 djm Exp $ */
|
/* $OpenBSD: sftp-client.c,v 1.81 2008/03/23 12:54:01 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
|
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
|
||||||
*
|
*
|
||||||
|
@ -65,6 +65,8 @@ struct sftp_conn {
|
||||||
u_int num_requests;
|
u_int num_requests;
|
||||||
u_int version;
|
u_int version;
|
||||||
u_int msg_id;
|
u_int msg_id;
|
||||||
|
#define SFTP_EXT_POSIX_RENAME 1
|
||||||
|
u_int exts;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -239,7 +241,7 @@ get_decode_stat(int fd, u_int expected_id, int quiet)
|
||||||
struct sftp_conn *
|
struct sftp_conn *
|
||||||
do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests)
|
do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests)
|
||||||
{
|
{
|
||||||
u_int type;
|
u_int type, exts = 0;
|
||||||
int version;
|
int version;
|
||||||
Buffer msg;
|
Buffer msg;
|
||||||
struct sftp_conn *ret;
|
struct sftp_conn *ret;
|
||||||
|
@ -270,6 +272,8 @@ do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests)
|
||||||
char *value = buffer_get_string(&msg, NULL);
|
char *value = buffer_get_string(&msg, NULL);
|
||||||
|
|
||||||
debug2("Init extension: \"%s\"", name);
|
debug2("Init extension: \"%s\"", name);
|
||||||
|
if (strcmp(name, "posix-rename@openssh.com") == 0)
|
||||||
|
exts |= SFTP_EXT_POSIX_RENAME;
|
||||||
xfree(name);
|
xfree(name);
|
||||||
xfree(value);
|
xfree(value);
|
||||||
}
|
}
|
||||||
|
@ -283,6 +287,7 @@ do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests)
|
||||||
ret->num_requests = num_requests;
|
ret->num_requests = num_requests;
|
||||||
ret->version = version;
|
ret->version = version;
|
||||||
ret->msg_id = 1;
|
ret->msg_id = 1;
|
||||||
|
ret->exts = exts;
|
||||||
|
|
||||||
/* Some filexfer v.0 servers don't support large packets */
|
/* Some filexfer v.0 servers don't support large packets */
|
||||||
if (version == 0)
|
if (version == 0)
|
||||||
|
@ -639,13 +644,20 @@ do_rename(struct sftp_conn *conn, char *oldpath, char *newpath)
|
||||||
|
|
||||||
/* Send rename request */
|
/* Send rename request */
|
||||||
id = conn->msg_id++;
|
id = conn->msg_id++;
|
||||||
buffer_put_char(&msg, SSH2_FXP_RENAME);
|
if ((conn->exts & SFTP_EXT_POSIX_RENAME)) {
|
||||||
buffer_put_int(&msg, id);
|
buffer_put_char(&msg, SSH2_FXP_EXTENDED);
|
||||||
|
buffer_put_int(&msg, id);
|
||||||
|
buffer_put_cstring(&msg, "posix-rename@openssh.com");
|
||||||
|
} else {
|
||||||
|
buffer_put_char(&msg, SSH2_FXP_RENAME);
|
||||||
|
buffer_put_int(&msg, id);
|
||||||
|
}
|
||||||
buffer_put_cstring(&msg, oldpath);
|
buffer_put_cstring(&msg, oldpath);
|
||||||
buffer_put_cstring(&msg, newpath);
|
buffer_put_cstring(&msg, newpath);
|
||||||
send_msg(conn->fd_out, &msg);
|
send_msg(conn->fd_out, &msg);
|
||||||
debug3("Sent message SSH2_FXP_RENAME \"%s\" -> \"%s\"", oldpath,
|
debug3("Sent message %s \"%s\" -> \"%s\"",
|
||||||
newpath);
|
(conn->exts & SFTP_EXT_POSIX_RENAME) ? "posix-rename@openssh.com" :
|
||||||
|
"SSH2_FXP_RENAME", oldpath, newpath);
|
||||||
buffer_free(&msg);
|
buffer_free(&msg);
|
||||||
|
|
||||||
status = get_status(conn->fd_in, id);
|
status = get_status(conn->fd_in, id);
|
||||||
|
|
Loading…
Reference in New Issue