summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--sftp-server.c27
2 files changed, 31 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 533ee81cf..0aa5c9920 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,11 @@
25 [clientloop.c packet.c packet.h serverloop.c] 25 [clientloop.c packet.c packet.h serverloop.c]
26 Allow all SSH2 packet types, including UNIMPLEMENTED to reset the 26 Allow all SSH2 packet types, including UNIMPLEMENTED to reset the
27 keepalive timer (bz #1307). ok markus@ 27 keepalive timer (bz #1307). ok markus@
28 - djm@cvs.openbsd.org 2008/02/27 20:21:15
29 [sftp-server.c]
30 add an extension method "posix-rename@openssh.com" to perform POSIX atomic
31 rename() operations. based on patch from miklos AT szeredi.hu in bz#1400;
32 ok dtucker@ markus@
28 33
2920080302 3420080302
30 - (dtucker) [configure.ac] FreeBSD's glob() doesn't behave the way we expect 35 - (dtucker) [configure.ac] FreeBSD's glob() doesn't behave the way we expect
@@ -3685,4 +3690,4 @@
3685 OpenServer 6 and add osr5bigcrypt support so when someone migrates 3690 OpenServer 6 and add osr5bigcrypt support so when someone migrates
3686 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 3691 passwords between UnixWare and OpenServer they will still work. OK dtucker@
3687 3692
3688$Id: ChangeLog,v 1.4856 2008/03/07 07:33:30 djm Exp $ 3693$Id: ChangeLog,v 1.4857 2008/03/07 07:33:53 djm Exp $
diff --git a/sftp-server.c b/sftp-server.c
index d3ae54428..d9549f5bc 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-server.c,v 1.77 2008/02/08 23:24:07 djm Exp $ */ 1/* $OpenBSD: sftp-server.c,v 1.78 2008/02/27 20:21:15 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000-2004 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000-2004 Markus Friedl. All rights reserved.
4 * 4 *
@@ -487,6 +487,9 @@ process_init(void)
487 buffer_init(&msg); 487 buffer_init(&msg);
488 buffer_put_char(&msg, SSH2_FXP_VERSION); 488 buffer_put_char(&msg, SSH2_FXP_VERSION);
489 buffer_put_int(&msg, SSH2_FILEXFER_VERSION); 489 buffer_put_int(&msg, SSH2_FILEXFER_VERSION);
490 /* POSIX rename extension */
491 buffer_put_cstring(&msg, "posix-rename@openssh.com");
492 buffer_put_cstring(&msg, "1"); /* version */
490 send_msg(&msg); 493 send_msg(&msg);
491 buffer_free(&msg); 494 buffer_free(&msg);
492} 495}
@@ -1080,6 +1083,23 @@ process_symlink(void)
1080} 1083}
1081 1084
1082static void 1085static void
1086process_extended_posix_rename(u_int32_t id)
1087{
1088 char *oldpath, *newpath;
1089
1090 oldpath = get_string(NULL);
1091 newpath = get_string(NULL);
1092 debug3("request %u: posix-rename", id);
1093 logit("posix-rename old \"%s\" new \"%s\"", oldpath, newpath);
1094 if (rename(oldpath, newpath) == -1)
1095 send_status(id, errno_to_portable(errno));
1096 else
1097 send_status(id, SSH2_FX_OK);
1098 xfree(oldpath);
1099 xfree(newpath);
1100}
1101
1102static void
1083process_extended(void) 1103process_extended(void)
1084{ 1104{
1085 u_int32_t id; 1105 u_int32_t id;
@@ -1087,7 +1107,10 @@ process_extended(void)
1087 1107
1088 id = get_int(); 1108 id = get_int();
1089 request = get_string(NULL); 1109 request = get_string(NULL);
1090 send_status(id, SSH2_FX_OP_UNSUPPORTED); /* MUST */ 1110 if (strcmp(request, "posix-rename@openssh.com") == 0)
1111 process_extended_posix_rename(id);
1112 else
1113 send_status(id, SSH2_FX_OP_UNSUPPORTED); /* MUST */
1091 xfree(request); 1114 xfree(request);
1092} 1115}
1093 1116