]> andersk Git - openssh.git/commitdiff
- djm@cvs.openbsd.org 2001/02/14 9:46:03
authormouring <mouring>
Thu, 15 Feb 2001 03:22:45 +0000 (03:22 +0000)
committermouring <mouring>
Thu, 15 Feb 2001 03:22:45 +0000 (03:22 +0000)
    [sftp-client.c sftp-int.c sftp.1]
    Fix and document 'preserve modes & times' option ('-p' flag in sftp);
    ok markus@

ChangeLog
sftp-client.c
sftp-int.c
sftp.1

index a65ea33eaef7fbe1bcec58c6431060a9fb1a7dd9..911589ebf35e015a048afa3272bc0be19232f3ac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
   - stevesk@cvs.openbsd.org 2001/02/12 20:53:33
     [sftp-int.c]
     lumask now works with 1 numeric arg; ok markus@, djm@
+  - 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@
 
 20010214
  - (djm) Don't try to close PAM session or delete credentials if the
index 8338dbc9f7109ff999789059c88732a52a6aee23..760a224e26dce08488499a05b7c8744f0c5c7874 100644 (file)
@@ -29,7 +29,7 @@
 /* XXX: copy between two remote sites */
 
 #include "includes.h"
-RCSID("$OpenBSD: sftp-client.c,v 1.9 2001/02/10 00:41:46 djm Exp $");
+RCSID("$OpenBSD: sftp-client.c,v 1.10 2001/02/14 09:46:03 djm Exp $");
 
 #include "ssh.h"
 #include "buffer.h"
@@ -577,20 +577,6 @@ do_download(int fd_in, int fd_out, char *remote_path, char *local_path,
                return(errno);
        }
 
-       /* Override umask and utimes if asked */
-       if (pflag && fchmod(local_fd, mode) == -1)
-               error("Couldn't set mode on \"%s\": %s", local_path,
-                   strerror(errno));
-       if (pflag && (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME)) {
-               struct timeval tv;
-
-               tv.tv_sec = a->atime;
-               tv.tv_usec = a->mtime;
-               if (utimes(local_path, &tv) == -1)
-                       error("Can't set times on \"%s\": %s", local_path,
-                           strerror(errno));
-       }
-
        buffer_init(&msg);
 
        /* Send open request */
@@ -675,6 +661,20 @@ do_download(int fd_in, int fd_out, char *remote_path, char *local_path,
        }
        status = do_close(fd_in, fd_out, handle, handle_len);
 
+       /* Override umask and utimes if asked */
+       if (pflag && fchmod(local_fd, mode) == -1)
+               error("Couldn't set mode on \"%s\": %s", local_path,
+                   strerror(errno));
+       if (pflag && (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME)) {
+               struct timeval tv[2];
+               tv[0].tv_sec = a->atime;
+               tv[1].tv_sec = a->mtime;
+               tv[0].tv_usec = tv[1].tv_usec = 0;
+               if (utimes(local_path, tv) == -1)
+                       error("Can't set times on \"%s\": %s", local_path,
+                           strerror(errno));
+       }
+
 done:
        close(local_fd);
        buffer_free(&msg);
@@ -735,10 +735,6 @@ do_upload(int fd_in, int fd_out, char *local_path, char *remote_path,
                return(-1);
        }
 
-       /* Override umask and utimes if asked */
-       if (pflag)
-               do_fsetstat(fd_in, fd_out, handle, handle_len, &a);
-
        /* Read from local and write to remote */
        offset = 0;
        for(;;) {
@@ -791,6 +787,10 @@ do_upload(int fd_in, int fd_out, char *local_path, char *remote_path,
                goto done;
        }
 
+       /* Override umask and utimes if asked */
+       if (pflag)
+               do_fsetstat(fd_in, fd_out, handle, handle_len, &a);
+
        status = do_close(fd_in, fd_out, handle, handle_len);
 
 done:
@@ -798,5 +798,3 @@ done:
        buffer_free(&msg);
        return status;
 }
-
-
index c236f6dac20ea2902405e4a449ac3e42863c493e..fd649822a844207cc5b48c1c8f46a5e106f9124f 100644 (file)
@@ -28,7 +28,7 @@
 /* XXX: recursive operations */
 
 #include "includes.h"
-RCSID("$OpenBSD: sftp-int.c,v 1.21 2001/02/12 20:53:33 stevesk Exp $");
+RCSID("$OpenBSD: sftp-int.c,v 1.22 2001/02/14 09:46:03 djm Exp $");
 
 #include "buffer.h"
 #include "xmalloc.h"
@@ -204,11 +204,12 @@ parse_getput_flags(const char **cpp, int *pflag)
        /* Check for flags */
        if (cp[0] == '-' && cp[1] && strchr(WHITESPACE, cp[2])) {
                switch (cp[1]) {
+               case 'p':
                case 'P':
                        *pflag = 1;
                        break;
                default:
-                       error("Invalid flag -%c", *cp);
+                       error("Invalid flag -%c", cp[1]);
                        return(-1);
                }
                cp += 2;
diff --git a/sftp.1 b/sftp.1
index 3b9d5124ebf6f331b146c19c89fbee53cf339202..635c07b2e547bc6d46d55e13e182bc5583c99f65 100644 (file)
--- a/sftp.1
+++ b/sftp.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sftp.1,v 1.6 2001/02/10 00:45:52 djm Exp $
+.\" $OpenBSD: sftp.1,v 1.7 2001/02/14 09:46:03 djm Exp $
 .\"
 .\" Copyright (c) 2001 Damien Miller. All rights reserved.
 .\"
@@ -94,13 +94,20 @@ to
 must be a numeric UID.
 .It Ic help
 Display help text.
-.It Ic get Ar remote-path Op Ar local-path
+.It Xo Ic get
+.Op Ar flags
+.Ar remote-path
+.Op Ar local-path
+.Xc
 Retrieve the
 .Ar remote-path
 and store it on the local machine.
 If the local
 path name is not specified, it is given the same name it has on the 
-remote machine.
+remote machine. If the 
+.Fl P
+flag is specified, then the file's full permission and access time are
+copied too.
 .It Ic lls Op Ar ls-options Op Ar path
 Display local directory listing of either 
 .Ar path
@@ -124,11 +131,18 @@ Set local umask to
 .It Ic mkdir Ar path
 Create remote directory specified by
 .Ar path .
-.It Ic put Ar local-path Op Ar remote-path
+.It Xo Ic put
+.Op Ar flags
+.Ar local-path
+.Op Ar local-path
+.Xc
 Upload
 .Ar local-path
 and store it on the remote machine. If the remote path name is not specified, 
-it is given the same name it has on the local machine.
+it is given the same name it has on the local machine. If the 
+.Fl P
+flag is specified, then the file's full permission and access time are
+copied too.
 .It Ic pwd
 Display remote working directory.
 .It Ic exit
This page took 0.258995 seconds and 5 git commands to generate.