[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.59 and 1.60

version 1.59, 2004/11/29 07:41:24 version 1.60, 2004/12/10 03:10:42
Line 741 
Line 741 
 {  {
         glob_t g;          glob_t g;
         int i, c = 1, colspace = 0, columns = 1;          int i, c = 1, colspace = 0, columns = 1;
         Attrib *a;          Attrib *a = NULL;
   
         memset(&g, 0, sizeof(g));          memset(&g, 0, sizeof(g));
   
         if (remote_glob(conn, path, GLOB_MARK|GLOB_NOCHECK|GLOB_BRACE,          if (remote_glob(conn, path, GLOB_MARK|GLOB_NOCHECK|GLOB_BRACE,
             NULL, &g)) {              NULL, &g) || (g.gl_pathc && !g.gl_matchc)) {
                   if (g.gl_pathc)
                           globfree(&g);
                 error("Can't ls: \"%s\" not found", path);                  error("Can't ls: \"%s\" not found", path);
                 return (-1);                  return (-1);
         }          }
Line 755 
Line 757 
                 goto out;                  goto out;
   
         /*          /*
          * If the glob returns a single match, which is the same as the           * If the glob returns a single match and it is a directory,
          * input glob, and it is a directory, then just list its contents           * then just list its contents.
          */           */
         if (g.gl_pathc == 1 &&          if (g.gl_matchc == 1) {
             strncmp(path, g.gl_pathv[0], strlen(g.gl_pathv[0]) - 1) == 0) {                  if ((a = do_lstat(conn, g.gl_pathv[0], 1)) == NULL) {
                 if ((a = do_lstat(conn, path, 1)) == NULL) {  
                         globfree(&g);                          globfree(&g);
                         return (-1);                          return (-1);
                 }                  }
                 if ((a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) &&                  if ((a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) &&
                     S_ISDIR(a->perm)) {                      S_ISDIR(a->perm)) {
                           int err;
   
                           err = do_ls_dir(conn, g.gl_pathv[0], strip_path, lflag);
                         globfree(&g);                          globfree(&g);
                         return (do_ls_dir(conn, path, strip_path, lflag));                          return (err);
                 }                  }
         }          }
   
Line 787 
Line 791 
                 colspace = width / columns;                  colspace = width / columns;
         }          }
   
         for (i = 0; g.gl_pathv[i] && !interrupted; i++) {          for (i = 0; g.gl_pathv[i] && !interrupted; i++, a = NULL) {
                 char *fname;                  char *fname;
   
                 fname = path_strip(g.gl_pathv[i], strip_path);                  fname = path_strip(g.gl_pathv[i], strip_path);
Line 804 
Line 808 
                          * that the server returns as well as the filenames.                           * that the server returns as well as the filenames.
                          */                           */
                         memset(&sb, 0, sizeof(sb));                          memset(&sb, 0, sizeof(sb));
                         a = do_lstat(conn, g.gl_pathv[i], 1);                          if (a == NULL)
                                   a = do_lstat(conn, g.gl_pathv[i], 1);
                         if (a != NULL)                          if (a != NULL)
                                 attrib_to_stat(a, &sb);                                  attrib_to_stat(a, &sb);
                         lname = ls_file(fname, &sb, 1);                          lname = ls_file(fname, &sb, 1);

Legend:
Removed from v.1.59  
changed lines
  Added in v.1.60