[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.131 and 1.132

version 1.131, 2010/10/23 22:06:12 version 1.132, 2010/12/04 00:18:01
Line 109 
Line 109 
 #define I_GET           5  #define I_GET           5
 #define I_HELP          6  #define I_HELP          6
 #define I_LCHDIR        7  #define I_LCHDIR        7
   #define I_LINK          25
 #define I_LLS           8  #define I_LLS           8
 #define I_LMKDIR        9  #define I_LMKDIR        9
 #define I_LPWD          10  #define I_LPWD          10
Line 153 
Line 154 
         { "lchdir",     I_LCHDIR,       LOCAL   },          { "lchdir",     I_LCHDIR,       LOCAL   },
         { "lls",        I_LLS,          LOCAL   },          { "lls",        I_LLS,          LOCAL   },
         { "lmkdir",     I_LMKDIR,       LOCAL   },          { "lmkdir",     I_LMKDIR,       LOCAL   },
         { "ln",         I_SYMLINK,      REMOTE  },          { "ln",         I_LINK,         REMOTE  },
         { "lpwd",       I_LPWD,         LOCAL   },          { "lpwd",       I_LPWD,         LOCAL   },
         { "ls",         I_LS,           REMOTE  },          { "ls",         I_LS,           REMOTE  },
         { "lumask",     I_LUMASK,       NOARGS  },          { "lumask",     I_LUMASK,       NOARGS  },
Line 217 
Line 218 
             "lcd path                           Change local directory to 'path'\n"              "lcd path                           Change local directory to 'path'\n"
             "lls [ls-options [path]]            Display local directory listing\n"              "lls [ls-options [path]]            Display local directory listing\n"
             "lmkdir path                        Create local directory\n"              "lmkdir path                        Create local directory\n"
             "ln oldpath newpath                 Symlink remote file\n"              "ln [-s] oldpath newpath            Link remote file (-s for symlink)\n"
             "lpwd                               Print local working directory\n"              "lpwd                               Print local working directory\n"
             "ls [-1afhlnrSt] [path]             Display remote directory listing\n"              "ls [-1afhlnrSt] [path]             Display remote directory listing\n"
             "lumask umask                       Set local umask to 'umask'\n"              "lumask umask                       Set local umask to 'umask'\n"
Line 354 
Line 355 
 }  }
   
 static int  static int
   parse_link_flags(const char *cmd, char **argv, int argc, int *sflag)
   {
           extern int opterr, optind, optopt, optreset;
           int ch;
   
           optind = optreset = 1;
           opterr = 0;
   
           *sflag = 0;
           while ((ch = getopt(argc, argv, "s")) != -1) {
                   switch (ch) {
                   case 's':
                           *sflag = 1;
                           break;
                   default:
                           error("%s: Invalid flag -%c", cmd, optopt);
                           return -1;
                   }
           }
   
           return optind;
   }
   
   static int
 parse_ls_flags(char **argv, int argc, int *lflag)  parse_ls_flags(char **argv, int argc, int *lflag)
 {  {
         extern int opterr, optind, optopt, optreset;          extern int opterr, optind, optopt, optreset;
Line 1065 
Line 1090 
   
 static int  static int
 parse_args(const char **cpp, int *pflag, int *rflag, int *lflag, int *iflag,  parse_args(const char **cpp, int *pflag, int *rflag, int *lflag, int *iflag,
     int *hflag, unsigned long *n_arg, char **path1, char **path2)      int *hflag, int *sflag, unsigned long *n_arg, char **path1, char **path2)
 {  {
         const char *cmd, *cp = *cpp;          const char *cmd, *cp = *cpp;
         char *cp2, **argv;          char *cp2, **argv;
Line 1115 
Line 1140 
         switch (cmdnum) {          switch (cmdnum) {
         case I_GET:          case I_GET:
         case I_PUT:          case I_PUT:
                 if ((optidx = parse_getput_flags(cmd, argv, argc, pflag, rflag)) == -1)                  if ((optidx = parse_getput_flags(cmd, argv, argc,
                       pflag, rflag)) == -1)
                         return -1;                          return -1;
                 /* Get first pathname (mandatory) */                  /* Get first pathname (mandatory) */
                 if (argc - optidx < 1) {                  if (argc - optidx < 1) {
Line 1131 
Line 1157 
                         undo_glob_escape(*path2);                          undo_glob_escape(*path2);
                 }                  }
                 break;                  break;
         case I_RENAME:          case I_LINK:
                   if ((optidx = parse_link_flags(cmd, argv, argc, sflag)) == -1)
                           return -1;
         case I_SYMLINK:          case I_SYMLINK:
           case I_RENAME:
                 if (argc - optidx < 2) {                  if (argc - optidx < 2) {
                         error("You must specify two paths after a %s "                          error("You must specify two paths after a %s "
                             "command.", cmd);                              "command.", cmd);
Line 1235 
Line 1264 
     int err_abort)      int err_abort)
 {  {
         char *path1, *path2, *tmp;          char *path1, *path2, *tmp;
         int pflag = 0, rflag = 0, lflag = 0, iflag = 0, hflag = 0, cmdnum, i;          int pflag = 0, rflag = 0, lflag = 0, iflag = 0, hflag = 0, sflag = 0;
           int cmdnum, i;
         unsigned long n_arg = 0;          unsigned long n_arg = 0;
         Attrib a, *aa;          Attrib a, *aa;
         char path_buf[MAXPATHLEN];          char path_buf[MAXPATHLEN];
Line 1243 
Line 1273 
         glob_t g;          glob_t g;
   
         path1 = path2 = NULL;          path1 = path2 = NULL;
         cmdnum = parse_args(&cmd, &pflag, &rflag, &lflag, &iflag, &hflag, &n_arg,          cmdnum = parse_args(&cmd, &pflag, &rflag, &lflag, &iflag, &hflag,
             &path1, &path2);              &sflag, &n_arg, &path1, &path2);
   
         if (iflag != 0)          if (iflag != 0)
                 err_abort = 0;                  err_abort = 0;
Line 1272 
Line 1302 
                 err = do_rename(conn, path1, path2);                  err = do_rename(conn, path1, path2);
                 break;                  break;
         case I_SYMLINK:          case I_SYMLINK:
                   sflag = 1;
           case I_LINK:
                   path1 = make_absolute(path1, *pwd);
                 path2 = make_absolute(path2, *pwd);                  path2 = make_absolute(path2, *pwd);
                 err = do_symlink(conn, path1, path2);                  err = (sflag ? do_symlink : do_hardlink)(conn, path1, path2);
                 break;                  break;
         case I_RM:          case I_RM:
                 path1 = make_absolute(path1, *pwd);                  path1 = make_absolute(path1, *pwd);

Legend:
Removed from v.1.131  
changed lines
  Added in v.1.132