summaryrefslogtreecommitdiff
path: root/sftp-client.c
diff options
context:
space:
mode:
Diffstat (limited to 'sftp-client.c')
-rw-r--r--sftp-client.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/sftp-client.c b/sftp-client.c
index 8338dbc9f..760a224e2 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -29,7 +29,7 @@
29/* XXX: copy between two remote sites */ 29/* XXX: copy between two remote sites */
30 30
31#include "includes.h" 31#include "includes.h"
32RCSID("$OpenBSD: sftp-client.c,v 1.9 2001/02/10 00:41:46 djm Exp $"); 32RCSID("$OpenBSD: sftp-client.c,v 1.10 2001/02/14 09:46:03 djm Exp $");
33 33
34#include "ssh.h" 34#include "ssh.h"
35#include "buffer.h" 35#include "buffer.h"
@@ -577,20 +577,6 @@ do_download(int fd_in, int fd_out, char *remote_path, char *local_path,
577 return(errno); 577 return(errno);
578 } 578 }
579 579
580 /* Override umask and utimes if asked */
581 if (pflag && fchmod(local_fd, mode) == -1)
582 error("Couldn't set mode on \"%s\": %s", local_path,
583 strerror(errno));
584 if (pflag && (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME)) {
585 struct timeval tv;
586
587 tv.tv_sec = a->atime;
588 tv.tv_usec = a->mtime;
589 if (utimes(local_path, &tv) == -1)
590 error("Can't set times on \"%s\": %s", local_path,
591 strerror(errno));
592 }
593
594 buffer_init(&msg); 580 buffer_init(&msg);
595 581
596 /* Send open request */ 582 /* Send open request */
@@ -675,6 +661,20 @@ do_download(int fd_in, int fd_out, char *remote_path, char *local_path,
675 } 661 }
676 status = do_close(fd_in, fd_out, handle, handle_len); 662 status = do_close(fd_in, fd_out, handle, handle_len);
677 663
664 /* Override umask and utimes if asked */
665 if (pflag && fchmod(local_fd, mode) == -1)
666 error("Couldn't set mode on \"%s\": %s", local_path,
667 strerror(errno));
668 if (pflag && (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME)) {
669 struct timeval tv[2];
670 tv[0].tv_sec = a->atime;
671 tv[1].tv_sec = a->mtime;
672 tv[0].tv_usec = tv[1].tv_usec = 0;
673 if (utimes(local_path, tv) == -1)
674 error("Can't set times on \"%s\": %s", local_path,
675 strerror(errno));
676 }
677
678done: 678done:
679 close(local_fd); 679 close(local_fd);
680 buffer_free(&msg); 680 buffer_free(&msg);
@@ -735,10 +735,6 @@ do_upload(int fd_in, int fd_out, char *local_path, char *remote_path,
735 return(-1); 735 return(-1);
736 } 736 }
737 737
738 /* Override umask and utimes if asked */
739 if (pflag)
740 do_fsetstat(fd_in, fd_out, handle, handle_len, &a);
741
742 /* Read from local and write to remote */ 738 /* Read from local and write to remote */
743 offset = 0; 739 offset = 0;
744 for(;;) { 740 for(;;) {
@@ -791,6 +787,10 @@ do_upload(int fd_in, int fd_out, char *local_path, char *remote_path,
791 goto done; 787 goto done;
792 } 788 }
793 789
790 /* Override umask and utimes if asked */
791 if (pflag)
792 do_fsetstat(fd_in, fd_out, handle, handle_len, &a);
793
794 status = do_close(fd_in, fd_out, handle, handle_len); 794 status = do_close(fd_in, fd_out, handle, handle_len);
795 795
796done: 796done:
@@ -798,5 +798,3 @@ done:
798 buffer_free(&msg); 798 buffer_free(&msg);
799 return status; 799 return status;
800} 800}
801
802