- djm@cvs.openbsd.org 2008/02/27 20:21:15

[sftp-server.c]
     add an extension method "posix-rename@openssh.com" to perform POSIX atomic
     rename() operations. based on patch from miklos AT szeredi.hu in bz#1400;
     ok dtucker@ markus@
This commit is contained in:
Damien Miller 2008-03-07 18:33:53 +11:00
parent 58226f6068
commit 7c29661471
2 changed files with 31 additions and 3 deletions

View File

@ -25,6 +25,11 @@
[clientloop.c packet.c packet.h serverloop.c]
Allow all SSH2 packet types, including UNIMPLEMENTED to reset the
keepalive timer (bz #1307). ok markus@
- djm@cvs.openbsd.org 2008/02/27 20:21:15
[sftp-server.c]
add an extension method "posix-rename@openssh.com" to perform POSIX atomic
rename() operations. based on patch from miklos AT szeredi.hu in bz#1400;
ok dtucker@ markus@
20080302
- (dtucker) [configure.ac] FreeBSD's glob() doesn't behave the way we expect
@ -3685,4 +3690,4 @@
OpenServer 6 and add osr5bigcrypt support so when someone migrates
passwords between UnixWare and OpenServer they will still work. OK dtucker@
$Id: ChangeLog,v 1.4856 2008/03/07 07:33:30 djm Exp $
$Id: ChangeLog,v 1.4857 2008/03/07 07:33:53 djm Exp $

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sftp-server.c,v 1.77 2008/02/08 23:24:07 djm Exp $ */
/* $OpenBSD: sftp-server.c,v 1.78 2008/02/27 20:21:15 djm Exp $ */
/*
* Copyright (c) 2000-2004 Markus Friedl. All rights reserved.
*
@ -487,6 +487,9 @@ process_init(void)
buffer_init(&msg);
buffer_put_char(&msg, SSH2_FXP_VERSION);
buffer_put_int(&msg, SSH2_FILEXFER_VERSION);
/* POSIX rename extension */
buffer_put_cstring(&msg, "posix-rename@openssh.com");
buffer_put_cstring(&msg, "1"); /* version */
send_msg(&msg);
buffer_free(&msg);
}
@ -1079,6 +1082,23 @@ process_symlink(void)
xfree(newpath);
}
static void
process_extended_posix_rename(u_int32_t id)
{
char *oldpath, *newpath;
oldpath = get_string(NULL);
newpath = get_string(NULL);
debug3("request %u: posix-rename", id);
logit("posix-rename old \"%s\" new \"%s\"", oldpath, newpath);
if (rename(oldpath, newpath) == -1)
send_status(id, errno_to_portable(errno));
else
send_status(id, SSH2_FX_OK);
xfree(oldpath);
xfree(newpath);
}
static void
process_extended(void)
{
@ -1087,7 +1107,10 @@ process_extended(void)
id = get_int();
request = get_string(NULL);
send_status(id, SSH2_FX_OP_UNSUPPORTED); /* MUST */
if (strcmp(request, "posix-rename@openssh.com") == 0)
process_extended_posix_rename(id);
else
send_status(id, SSH2_FX_OP_UNSUPPORTED); /* MUST */
xfree(request);
}