summaryrefslogtreecommitdiff
path: root/sftp-server.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2002-02-13 14:05:00 +1100
committerDamien Miller <djm@mindrot.org>2002-02-13 14:05:00 +1100
commit00c9217558c23bbde7567dd996c5686f473869c2 (patch)
tree0c21a305932eae1cc65711104ff1f6979b683d35 /sftp-server.c
parent5873dfd829558cd3fdeb56f22c893b3fdc8e87c9 (diff)
- markus@cvs.openbsd.org 2002/02/13 00:28:13
[sftp-server.c] handle SSH2_FILEXFER_ATTR_SIZE in SSH2_FXP_(F)SETSTAT; ok djm@
Diffstat (limited to 'sftp-server.c')
-rw-r--r--sftp-server.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/sftp-server.c b/sftp-server.c
index 6d6658614..117e6cc15 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 2 * Copyright (c) 2000, 2001, 2002 Markus Friedl. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
@@ -22,7 +22,7 @@
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24#include "includes.h" 24#include "includes.h"
25RCSID("$OpenBSD: sftp-server.c,v 1.32 2001/12/29 21:56:01 stevesk Exp $"); 25RCSID("$OpenBSD: sftp-server.c,v 1.33 2002/02/13 00:28:13 markus Exp $");
26 26
27#include "buffer.h" 27#include "buffer.h"
28#include "bufaux.h" 28#include "bufaux.h"
@@ -589,6 +589,11 @@ process_setstat(void)
589 name = get_string(NULL); 589 name = get_string(NULL);
590 a = get_attrib(); 590 a = get_attrib();
591 TRACE("setstat id %d name %s", id, name); 591 TRACE("setstat id %d name %s", id, name);
592 if (a->flags & SSH2_FILEXFER_ATTR_SIZE) {
593 ret = truncate(name, a->size);
594 if (ret == -1)
595 status = errno_to_portable(errno);
596 }
592 if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) { 597 if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) {
593 ret = chmod(name, a->perm & 0777); 598 ret = chmod(name, a->perm & 0777);
594 if (ret == -1) 599 if (ret == -1)
@@ -626,6 +631,11 @@ process_fsetstat(void)
626 if (fd < 0 || name == NULL) { 631 if (fd < 0 || name == NULL) {
627 status = SSH2_FX_FAILURE; 632 status = SSH2_FX_FAILURE;
628 } else { 633 } else {
634 if (a->flags & SSH2_FILEXFER_ATTR_SIZE) {
635 ret = ftruncate(fd, a->size);
636 if (ret == -1)
637 status = errno_to_portable(errno);
638 }
629 if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) { 639 if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) {
630#ifdef HAVE_FCHMOD 640#ifdef HAVE_FCHMOD
631 ret = fchmod(fd, a->perm & 0777); 641 ret = fchmod(fd, a->perm & 0777);