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

Diff for /src/usr.bin/ssh/sftp-server.c between version 1.128 and 1.129

version 1.128, 2021/06/06 03:15:39 version 1.129, 2021/08/09 23:47:44
Line 107 
Line 107 
 static void process_extended_fsync(u_int32_t id);  static void process_extended_fsync(u_int32_t id);
 static void process_extended_lsetstat(u_int32_t id);  static void process_extended_lsetstat(u_int32_t id);
 static void process_extended_limits(u_int32_t id);  static void process_extended_limits(u_int32_t id);
   static void process_extended_expand(u_int32_t id);
 static void process_extended(u_int32_t id);  static void process_extended(u_int32_t id);
   
 struct sftp_handler {  struct sftp_handler {
Line 150 
Line 151 
         { "fsync", "fsync@openssh.com", 0, process_extended_fsync, 1 },          { "fsync", "fsync@openssh.com", 0, process_extended_fsync, 1 },
         { "lsetstat", "lsetstat@openssh.com", 0, process_extended_lsetstat, 1 },          { "lsetstat", "lsetstat@openssh.com", 0, process_extended_lsetstat, 1 },
         { "limits", "limits@openssh.com", 0, process_extended_limits, 0 },          { "limits", "limits@openssh.com", 0, process_extended_limits, 0 },
           { "expand-path", "expand-path@openssh.com", 0,
               process_extended_expand, 0 },
         { NULL, NULL, 0, NULL, 0 }          { NULL, NULL, 0, NULL, 0 }
 };  };
   
Line 698 
Line 701 
         compose_extension(msg, "fsync@openssh.com", "1");          compose_extension(msg, "fsync@openssh.com", "1");
         compose_extension(msg, "lsetstat@openssh.com", "1");          compose_extension(msg, "lsetstat@openssh.com", "1");
         compose_extension(msg, "limits@openssh.com", "1");          compose_extension(msg, "limits@openssh.com", "1");
           compose_extension(msg, "expand-path@openssh.com", "1");
   
         send_msg(msg);          send_msg(msg);
         sshbuf_free(msg);          sshbuf_free(msg);
Line 1486 
Line 1490 
                 fatal_fr(r, "compose");                  fatal_fr(r, "compose");
         send_msg(msg);          send_msg(msg);
         sshbuf_free(msg);          sshbuf_free(msg);
   }
   
   static void
   process_extended_expand(u_int32_t id)
   {
           char cwd[PATH_MAX], resolvedname[PATH_MAX];
           char *path, *npath;
           int r;
           Stat s;
   
           if ((r = sshbuf_get_cstring(iqueue, &path, NULL)) != 0)
                   fatal_fr(r, "parse");
           if (getcwd(cwd, sizeof(cwd)) == NULL) {
                   send_status(id, errno_to_portable(errno));
                   goto out;
           }
   
           debug3("request %u: expand, original \"%s\"", id, path);
           if (path[0] == '\0') {
                   /* empty path */
                   free(path);
                   path = xstrdup(".");
           } else if (*path == '~') {
                   /* ~ expand path */
                   /* Special-case for "~" and "~/" to respect homedir flag */
                   if (strcmp(path, "~") == 0) {
                           free(path);
                           path = xstrdup(cwd);
                   } else if (strncmp(path, "~/", 2) == 0) {
                           npath = xstrdup(path + 2);
                           free(path);
                           xasprintf(&path, "%s/%s", cwd, npath);
                   } else {
                           /* ~user expansions */
                           if (tilde_expand(path, pw->pw_uid, &npath) != 0) {
                                   send_status(id, errno_to_portable(EINVAL));
                                   goto out;
                           }
                           free(path);
                           path = npath;
                   }
           } else if (*path != '/') {
                   /* relative path */
                   xasprintf(&npath, "%s/%s", cwd, path);
                   free(path);
                   path = npath;
           }
           verbose("expand \"%s\"", path);
           if (sftp_realpath(path, resolvedname) == NULL) {
                   send_status(id, errno_to_portable(errno));
                   goto out;
           }
           attrib_clear(&s.attrib);
           s.name = s.long_name = resolvedname;
           send_names(id, 1, &s);
    out:
           free(path);
 }  }
   
 static void  static void

Legend:
Removed from v.1.128  
changed lines
  Added in v.1.129