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

Diff for /src/usr.bin/ssh/ssh.c between version 1.526 and 1.527

version 1.526, 2020/04/03 06:07:57 version 1.527, 2020/04/10 00:52:07
Line 160 
Line 160 
 /* Various strings used to to percent_expand() arguments */  /* Various strings used to to percent_expand() arguments */
 static char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV];  static char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV];
 static char uidstr[32], *host_arg, *conn_hash_hex;  static char uidstr[32], *host_arg, *conn_hash_hex;
 #define DEFAULT_CLIENT_PERCENT_EXPAND_ARGS \  
     "C", conn_hash_hex, \  
     "L", shorthost, \  
     "i", uidstr, \  
     "l", thishost, \  
     "n", host_arg, \  
     "p", portstr  
   
 /* socket address the host resolves to */  /* socket address the host resolves to */
 struct sockaddr_storage hostaddr;  struct sockaddr_storage hostaddr;
Line 222 
Line 215 
         }          }
 }  }
   
   #define DEFAULT_CLIENT_PERCENT_EXPAND_ARGS \
       "C", conn_hash_hex, \
       "L", shorthost, \
       "i", uidstr, \
       "l", thishost, \
       "n", host_arg, \
       "p", portstr
   
 /*  /*
    * Expands the set of percent_expand options used by the majority of keywords
    * in the client that support percent expansion.
    * Caller must free returned string.
    */
   static char *
   default_client_percent_expand(const char *str, const char *homedir,
       const char *remhost, const char *remuser, const char *locuser)
   {
           return percent_expand(str,
               /* values from statics above */
               DEFAULT_CLIENT_PERCENT_EXPAND_ARGS,
               /* values from arguments */
               "d", homedir,
               "h", remhost,
               "r", remuser,
               "u", locuser,
               (char *)NULL);
   }
   
   /*
  * Attempt to resolve a host name / port to a set of addresses and   * Attempt to resolve a host name / port to a set of addresses and
  * optionally return any CNAMEs encountered along the way.   * optionally return any CNAMEs encountered along the way.
  * Returns NULL on failure.   * Returns NULL on failure.
Line 1324 
Line 1345 
         if (options.remote_command != NULL) {          if (options.remote_command != NULL) {
                 debug3("expanding RemoteCommand: %s", options.remote_command);                  debug3("expanding RemoteCommand: %s", options.remote_command);
                 cp = options.remote_command;                  cp = options.remote_command;
                 options.remote_command = percent_expand(cp,                  options.remote_command = default_client_percent_expand(cp,
                     DEFAULT_CLIENT_PERCENT_EXPAND_ARGS,                      pw->pw_dir, host, options.user, pw->pw_name);
                     "d", pw->pw_dir,  
                     "h", host,  
                     "r", options.user,  
                     "u", pw->pw_name,  
                     (char *)NULL);  
                 debug3("expanded RemoteCommand: %s", options.remote_command);                  debug3("expanded RemoteCommand: %s", options.remote_command);
                 free(cp);                  free(cp);
                 if ((r = sshbuf_put(command, options.remote_command,                  if ((r = sshbuf_put(command, options.remote_command,
Line 1341 
Line 1357 
         if (options.control_path != NULL) {          if (options.control_path != NULL) {
                 cp = tilde_expand_filename(options.control_path, getuid());                  cp = tilde_expand_filename(options.control_path, getuid());
                 free(options.control_path);                  free(options.control_path);
                 options.control_path = percent_expand(cp,                  options.control_path = default_client_percent_expand(cp,
                     DEFAULT_CLIENT_PERCENT_EXPAND_ARGS,                      pw->pw_dir, host, options.user, pw->pw_name);
                     "d", pw->pw_dir,  
                     "h", host,  
                     "r", options.user,  
                     "u", pw->pw_name,  
                     (char *)NULL);  
                 free(cp);                  free(cp);
         }          }
   
         if (options.identity_agent != NULL) {          if (options.identity_agent != NULL) {
                 p = tilde_expand_filename(options.identity_agent, getuid());                  p = tilde_expand_filename(options.identity_agent, getuid());
                 cp = percent_expand(p,                  cp = default_client_percent_expand(p,
                     DEFAULT_CLIENT_PERCENT_EXPAND_ARGS,                      pw->pw_dir, host, options.user, pw->pw_name);
                     "d", pw->pw_dir,  
                     "h", host,  
                     "r", options.user,  
                     "u", pw->pw_name,  
                     (char *)NULL);  
                 free(p);                  free(p);
                 free(options.identity_agent);                  free(options.identity_agent);
                 options.identity_agent = cp;                  options.identity_agent = cp;
Line 1368 
Line 1374 
         if (options.forward_agent_sock_path != NULL) {          if (options.forward_agent_sock_path != NULL) {
                 p = tilde_expand_filename(options.forward_agent_sock_path,                  p = tilde_expand_filename(options.forward_agent_sock_path,
                     getuid());                      getuid());
                 cp = percent_expand(p,                  cp = default_client_percent_expand(p,
                     DEFAULT_CLIENT_PERCENT_EXPAND_ARGS,                      pw->pw_dir, host, options.user, pw->pw_name);
                     "d", pw->pw_dir,  
                     "h", host,  
                     "r", options.user,  
                     "u", pw->pw_name,  
                     (char *)NULL);  
                 free(p);                  free(p);
                 free(options.forward_agent_sock_path);                  free(options.forward_agent_sock_path);
                 options.forward_agent_sock_path = cp;                  options.forward_agent_sock_path = cp;
         }          }
   
           for (i = 0; i < options.num_local_forwards; i++) {
                   if (options.local_forwards[i].listen_path != NULL) {
                           cp = options.local_forwards[i].listen_path;
                           p = options.local_forwards[i].listen_path =
                               default_client_percent_expand(cp,
                               pw->pw_dir, host, options.user, pw->pw_name);
                           if (strcmp(cp, p) != 0)
                                   debug3("expanded LocalForward listen path "
                                       "'%s' -> '%s'", cp, p);
                           free(cp);
                   }
                   if (options.local_forwards[i].connect_path != NULL) {
                           cp = options.local_forwards[i].connect_path;
                           p = options.local_forwards[i].connect_path =
                               default_client_percent_expand(cp,
                               pw->pw_dir, host, options.user, pw->pw_name);
                           if (strcmp(cp, p) != 0)
                                   debug3("expanded LocalForward connect path "
                                       "'%s' -> '%s'", cp, p);
                           free(cp);
                   }
           }
   
           for (i = 0; i < options.num_remote_forwards; i++) {
                   if (options.remote_forwards[i].listen_path != NULL) {
                           cp = options.remote_forwards[i].listen_path;
                           p = options.remote_forwards[i].listen_path =
                               default_client_percent_expand(cp,
                               pw->pw_dir, host, options.user, pw->pw_name);
                           if (strcmp(cp, p) != 0)
                                   debug3("expanded RemoteForward listen path "
                                       "'%s' -> '%s'", cp, p);
                           free(cp);
                   }
                   if (options.remote_forwards[i].connect_path != NULL) {
                           cp = options.remote_forwards[i].connect_path;
                           p = options.remote_forwards[i].connect_path =
                               default_client_percent_expand(cp,
                               pw->pw_dir, host, options.user, pw->pw_name);
                           if (strcmp(cp, p) != 0)
                                   debug3("expanded RemoteForward connect path "
                                       "'%s' -> '%s'", cp, p);
                           free(cp);
                   }
           }
   
         if (config_test) {          if (config_test) {
                 dump_client_config(&options, host);                  dump_client_config(&options, host);
                 exit(0);                  exit(0);
Line 2127 
Line 2174 
                         continue;                          continue;
                 }                  }
                 cp = tilde_expand_filename(options.identity_files[i], getuid());                  cp = tilde_expand_filename(options.identity_files[i], getuid());
                 filename = percent_expand(cp,                  filename = default_client_percent_expand(cp,
                     DEFAULT_CLIENT_PERCENT_EXPAND_ARGS,                      pw->pw_dir, host, options.user, pw->pw_name);
                     "d", pw->pw_dir,  
                     "h", host,  
                     "r", options.user,  
                     "u", pw->pw_name,  
                     (char *)NULL);  
                 free(cp);                  free(cp);
                 check_load(sshkey_load_public(filename, &public, NULL),                  check_load(sshkey_load_public(filename, &public, NULL),
                     filename, "pubkey");                      filename, "pubkey");
Line 2182 
Line 2224 
         for (i = 0; i < options.num_certificate_files; i++) {          for (i = 0; i < options.num_certificate_files; i++) {
                 cp = tilde_expand_filename(options.certificate_files[i],                  cp = tilde_expand_filename(options.certificate_files[i],
                     getuid());                      getuid());
                 filename = percent_expand(cp,                  filename = default_client_percent_expand(cp,
                     DEFAULT_CLIENT_PERCENT_EXPAND_ARGS,                      pw->pw_dir, host, options.user, pw->pw_name);
                     "d", pw->pw_dir,  
                     "h", host,  
                     "r", options.user,  
                     "u", pw->pw_name,  
                     (char *)NULL);  
                 free(cp);                  free(cp);
   
                 check_load(sshkey_load_public(filename, &public, NULL),                  check_load(sshkey_load_public(filename, &public, NULL),

Legend:
Removed from v.1.526  
changed lines
  Added in v.1.527