[BACK]Return to scp.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/scp.c between version 1.225 and 1.226

version 1.225, 2021/08/09 07:21:01 version 1.226, 2021/08/09 23:44:32
Line 1220 
Line 1220 
         free(src);          free(src);
 }  }
   
   /* Canonicalise a remote path, handling ~ by assuming cwd is the homedir */
   static char *
   absolute_remote_path(const char *path, const char *remote_path)
   {
           char *ret;
   
           /* Handle ~ prefixed paths */
           if (*path != '~')
                   ret = xstrdup(path);
           else {
                   if (strcmp(path, "~") == 0)
                           ret = xstrdup("");
                   else if (strncmp(path, "~/", 2) == 0)
                           ret = xstrdup(path + 2);
                   else {
                           /* XXX could be supported with protocol extension */
                           error("~user paths are not currently supported");
                           return NULL;
                   }
           }
           return make_absolute(ret, remote_path);
   }
   
 void  void
 source_sftp(int argc, char *src, char *targ,  source_sftp(int argc, char *src, char *targ,
     struct sftp_conn *conn, char **remote_path)      struct sftp_conn *conn, char **remote_path)
Line 1240 
Line 1263 
          * No need to glob here - the local shell already took care of           * No need to glob here - the local shell already took care of
          * the expansions           * the expansions
          */           */
         target = xstrdup(targ);          if ((target = absolute_remote_path(targ, *remote_path)) == NULL)
         target = make_absolute(target, *remote_path);                  cleanup_exit(255);
         target_is_dir = remote_is_dir(conn, target);          target_is_dir = remote_is_dir(conn, target);
         if (targetshouldbedirectory && !target_is_dir) {          if (targetshouldbedirectory && !target_is_dir) {
                 fatal("Target is not a directory, but more files selected "                  fatal("Target is not a directory, but more files selected "
Line 1438 
Line 1461 
         char *filename, *tmp = NULL, *remote_path = NULL;          char *filename, *tmp = NULL, *remote_path = NULL;
         int i, r, err = 0;          int i, r, err = 0;
   
           memset(&g, 0, sizeof(g));
         /*          /*
          * Here, we need remote glob as SFTP can not depend on remote shell           * Here, we need remote glob as SFTP can not depend on remote shell
          * expansions           * expansions
Line 1451 
Line 1475 
                 goto out;                  goto out;
         }          }
   
         abs_src = xstrdup(src);          if ((abs_src = absolute_remote_path(src, remote_path)) == NULL) {
         abs_src = make_absolute(abs_src, remote_path);                  err = -1;
                   goto out;
           }
         free(remote_path);          free(remote_path);
         memset(&g, 0, sizeof(g));  
   
         debug3_f("copying remote %s to local %s", abs_src, dst);          debug3_f("copying remote %s to local %s", abs_src, dst);
         if ((r = remote_glob(conn, abs_src, GLOB_MARK, NULL, &g)) != 0) {          if ((r = remote_glob(conn, abs_src, GLOB_MARK, NULL, &g)) != 0) {
Line 1854 
Line 1879 
         if ((filename = basename(src)) == NULL)          if ((filename = basename(src)) == NULL)
                 fatal("basename %s: %s", src, strerror(errno));                  fatal("basename %s: %s", src, strerror(errno));
   
         abs_src = xstrdup(src);          if ((abs_src = absolute_remote_path(src, from_remote_path)) == NULL ||
         abs_src = make_absolute(abs_src, from_remote_path);              (target = absolute_remote_path(targ, *to_remote_path)) == NULL)
                   cleanup_exit(255);
         free(from_remote_path);          free(from_remote_path);
         target = xstrdup(targ);  
         target = make_absolute(target, *to_remote_path);  
         memset(&g, 0, sizeof(g));          memset(&g, 0, sizeof(g));
   
         targetisdir = remote_is_dir(to, target);          targetisdir = remote_is_dir(to, target);

Legend:
Removed from v.1.225  
changed lines
  Added in v.1.226