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

Diff for /src/usr.bin/ssh/sftp.c between version 1.181 and 1.182

version 1.181, 2017/10/21 23:06:24 version 1.182, 2017/11/03 03:46:52
Line 195 
Line 195 
         { NULL,         -1,             -1      }          { NULL,         -1,             -1      }
 };  };
   
 int interactive_loop(struct sftp_conn *, char *file1, char *file2);  
   
 /* ARGSUSED */  /* ARGSUSED */
 static void  static void
 killchild(int signo)  killchild(int signo)
Line 1260 
Line 1258 
         char *cp2, **argv;          char *cp2, **argv;
         int base = 0;          int base = 0;
         long l;          long l;
         int i, cmdnum, optidx, argc;          int path1_mandatory = 0, i, cmdnum, optidx, argc;
   
         /* Skip leading whitespace */          /* Skip leading whitespace */
         cp = cp + strspn(cp, WHITESPACE);          cp = cp + strspn(cp, WHITESPACE);
Line 1350 
Line 1348 
         case I_RM:          case I_RM:
         case I_MKDIR:          case I_MKDIR:
         case I_RMDIR:          case I_RMDIR:
           case I_LMKDIR:
                   path1_mandatory = 1;
                   /* FALLTHROUGH */
         case I_CHDIR:          case I_CHDIR:
         case I_LCHDIR:          case I_LCHDIR:
         case I_LMKDIR:  
                 if ((optidx = parse_no_flags(cmd, argv, argc)) == -1)                  if ((optidx = parse_no_flags(cmd, argv, argc)) == -1)
                         return -1;                          return -1;
                 /* Get pathname (mandatory) */                  /* Get pathname (mandatory) */
                 if (argc - optidx < 1) {                  if (argc - optidx < 1) {
                           if (!path1_mandatory)
                                   break; /* return a NULL path1 */
                         error("You must specify a path after a %s command.",                          error("You must specify a path after a %s command.",
                             cmd);                              cmd);
                         return -1;                          return -1;
Line 1441 
Line 1443 
   
 static int  static int
 parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,  parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd,
     int err_abort)      const char *startdir, int err_abort)
 {  {
         char *path1, *path2, *tmp;          char *path1, *path2, *tmp;
         int ignore_errors = 0, aflag = 0, fflag = 0, hflag = 0,          int ignore_errors = 0, aflag = 0, fflag = 0, hflag = 0,
Line 1521 
Line 1523 
                 err = do_rmdir(conn, path1);                  err = do_rmdir(conn, path1);
                 break;                  break;
         case I_CHDIR:          case I_CHDIR:
                   if (path1 == NULL || *path1 == '\0')
                           path1 = xstrdup(startdir);
                 path1 = make_absolute(path1, *pwd);                  path1 = make_absolute(path1, *pwd);
                 if ((tmp = do_realpath(conn, path1)) == NULL) {                  if ((tmp = do_realpath(conn, path1)) == NULL) {
                         err = 1;                          err = 1;
Line 1569 
Line 1573 
                 err = do_df(conn, path1, hflag, iflag);                  err = do_df(conn, path1, hflag, iflag);
                 break;                  break;
         case I_LCHDIR:          case I_LCHDIR:
                   if (path1 == NULL || *path1 == '\0')
                           path1 = xstrdup("~");
                 tmp = tilde_expand_filename(path1, getuid());                  tmp = tilde_expand_filename(path1, getuid());
                 free(path1);                  free(path1);
                 path1 = tmp;                  path1 = tmp;
Line 2053 
Line 2059 
         return ret;          return ret;
 }  }
   
 int  static int
 interactive_loop(struct sftp_conn *conn, char *file1, char *file2)  interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
 {  {
         char *remote_path;          char *remote_path;
         char *dir = NULL;          char *dir = NULL, *startdir = NULL;
         char cmd[2048];          char cmd[2048];
         int err, interactive;          int err, interactive;
         EditLine *el = NULL;          EditLine *el = NULL;
Line 2099 
Line 2105 
         remote_path = do_realpath(conn, ".");          remote_path = do_realpath(conn, ".");
         if (remote_path == NULL)          if (remote_path == NULL)
                 fatal("Need cwd");                  fatal("Need cwd");
           startdir = xstrdup(remote_path);
   
         if (file1 != NULL) {          if (file1 != NULL) {
                 dir = xstrdup(file1);                  dir = xstrdup(file1);
Line 2109 
Line 2116 
                                 mprintf("Changing to: %s\n", dir);                                  mprintf("Changing to: %s\n", dir);
                         snprintf(cmd, sizeof cmd, "cd \"%s\"", dir);                          snprintf(cmd, sizeof cmd, "cd \"%s\"", dir);
                         if (parse_dispatch_command(conn, cmd,                          if (parse_dispatch_command(conn, cmd,
                             &remote_path, 1) != 0) {                              &remote_path, startdir, 1) != 0) {
                                 free(dir);                                  free(dir);
                                   free(startdir);
                                 free(remote_path);                                  free(remote_path);
                                 free(conn);                                  free(conn);
                                 return (-1);                                  return (-1);
Line 2122 
Line 2130 
                             file2 == NULL ? "" : " ",                              file2 == NULL ? "" : " ",
                             file2 == NULL ? "" : file2);                              file2 == NULL ? "" : file2);
                         err = parse_dispatch_command(conn, cmd,                          err = parse_dispatch_command(conn, cmd,
                             &remote_path, 1);                              &remote_path, startdir, 1);
                         free(dir);                          free(dir);
                           free(startdir);
                         free(remote_path);                          free(remote_path);
                         free(conn);                          free(conn);
                         return (err);                          return (err);
Line 2179 
Line 2188 
                 signal(SIGINT, cmd_interrupt);                  signal(SIGINT, cmd_interrupt);
   
                 err = parse_dispatch_command(conn, cmd, &remote_path,                  err = parse_dispatch_command(conn, cmd, &remote_path,
                     batchmode);                      startdir, batchmode);
                 if (err != 0)                  if (err != 0)
                         break;                          break;
         }          }
         free(remote_path);          free(remote_path);
           free(startdir);
         free(conn);          free(conn);
   
         if (el != NULL)          if (el != NULL)

Legend:
Removed from v.1.181  
changed lines
  Added in v.1.182