summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-02-15 03:22:45 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-02-15 03:22:45 +0000
commit9d4f2c808caa5af966c54de9a89c4a9ce1ef48a6 (patch)
treec3d91c2a0ee30b6eeefc0af1faf7355de9e672eb
parent6690494f2125a5576cde11f7642e5ba70c91579c (diff)
- djm@cvs.openbsd.org 2001/02/14 9:46:03
[sftp-client.c sftp-int.c sftp.1] Fix and document 'preserve modes & times' option ('-p' flag in sftp); ok markus@
-rw-r--r--ChangeLog6
-rw-r--r--sftp-client.c40
-rw-r--r--sftp-int.c5
-rw-r--r--sftp.124
4 files changed, 46 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index 99654a04c..7da95d3c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -32,6 +32,10 @@
32 - stevesk@cvs.openbsd.org 2001/02/12 20:53:33 32 - stevesk@cvs.openbsd.org 2001/02/12 20:53:33
33 [sftp-int.c] 33 [sftp-int.c]
34 lumask now works with 1 numeric arg; ok markus@, djm@ 34 lumask now works with 1 numeric arg; ok markus@, djm@
35 - djm@cvs.openbsd.org 2001/02/14 9:46:03
36 [sftp-client.c sftp-int.c sftp.1]
37 Fix and document 'preserve modes & times' option ('-p' flag in sftp);
38 ok markus@
35 39
3620010214 4020010214
37 - (djm) Don't try to close PAM session or delete credentials if the 41 - (djm) Don't try to close PAM session or delete credentials if the
@@ -3960,4 +3964,4 @@
3960 - Wrote replacements for strlcpy and mkdtemp 3964 - Wrote replacements for strlcpy and mkdtemp
3961 - Released 1.0pre1 3965 - Released 1.0pre1
3962 3966
3963$Id: ChangeLog,v 1.768 2001/02/15 03:19:56 mouring Exp $ 3967$Id: ChangeLog,v 1.769 2001/02/15 03:22:45 mouring Exp $
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
diff --git a/sftp-int.c b/sftp-int.c
index c236f6dac..fd649822a 100644
--- a/sftp-int.c
+++ b/sftp-int.c
@@ -28,7 +28,7 @@
28/* XXX: recursive operations */ 28/* XXX: recursive operations */
29 29
30#include "includes.h" 30#include "includes.h"
31RCSID("$OpenBSD: sftp-int.c,v 1.21 2001/02/12 20:53:33 stevesk Exp $"); 31RCSID("$OpenBSD: sftp-int.c,v 1.22 2001/02/14 09:46:03 djm Exp $");
32 32
33#include "buffer.h" 33#include "buffer.h"
34#include "xmalloc.h" 34#include "xmalloc.h"
@@ -204,11 +204,12 @@ parse_getput_flags(const char **cpp, int *pflag)
204 /* Check for flags */ 204 /* Check for flags */
205 if (cp[0] == '-' && cp[1] && strchr(WHITESPACE, cp[2])) { 205 if (cp[0] == '-' && cp[1] && strchr(WHITESPACE, cp[2])) {
206 switch (cp[1]) { 206 switch (cp[1]) {
207 case 'p':
207 case 'P': 208 case 'P':
208 *pflag = 1; 209 *pflag = 1;
209 break; 210 break;
210 default: 211 default:
211 error("Invalid flag -%c", *cp); 212 error("Invalid flag -%c", cp[1]);
212 return(-1); 213 return(-1);
213 } 214 }
214 cp += 2; 215 cp += 2;
diff --git a/sftp.1 b/sftp.1
index 3b9d5124e..635c07b2e 100644
--- a/sftp.1
+++ b/sftp.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: sftp.1,v 1.6 2001/02/10 00:45:52 djm Exp $ 1.\" $OpenBSD: sftp.1,v 1.7 2001/02/14 09:46:03 djm Exp $
2.\" 2.\"
3.\" Copyright (c) 2001 Damien Miller. All rights reserved. 3.\" Copyright (c) 2001 Damien Miller. All rights reserved.
4.\" 4.\"
@@ -94,13 +94,20 @@ to
94must be a numeric UID. 94must be a numeric UID.
95.It Ic help 95.It Ic help
96Display help text. 96Display help text.
97.It Ic get Ar remote-path Op Ar local-path 97.It Xo Ic get
98.Op Ar flags
99.Ar remote-path
100.Op Ar local-path
101.Xc
98Retrieve the 102Retrieve the
99.Ar remote-path 103.Ar remote-path
100and store it on the local machine. 104and store it on the local machine.
101If the local 105If the local
102path name is not specified, it is given the same name it has on the 106path name is not specified, it is given the same name it has on the
103remote machine. 107remote machine. If the
108.Fl P
109flag is specified, then the file's full permission and access time are
110copied too.
104.It Ic lls Op Ar ls-options Op Ar path 111.It Ic lls Op Ar ls-options Op Ar path
105Display local directory listing of either 112Display local directory listing of either
106.Ar path 113.Ar path
@@ -124,11 +131,18 @@ Set local umask to
124.It Ic mkdir Ar path 131.It Ic mkdir Ar path
125Create remote directory specified by 132Create remote directory specified by
126.Ar path . 133.Ar path .
127.It Ic put Ar local-path Op Ar remote-path 134.It Xo Ic put
135.Op Ar flags
136.Ar local-path
137.Op Ar local-path
138.Xc
128Upload 139Upload
129.Ar local-path 140.Ar local-path
130and store it on the remote machine. If the remote path name is not specified, 141and store it on the remote machine. If the remote path name is not specified,
131it is given the same name it has on the local machine. 142it is given the same name it has on the local machine. If the
143.Fl P
144flag is specified, then the file's full permission and access time are
145copied too.
132.It Ic pwd 146.It Ic pwd
133Display remote working directory. 147Display remote working directory.
134.It Ic exit 148.It Ic exit