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

Diff for /src/usr.bin/ssh/servconf.c between version 1.388 and 1.389

version 1.388, 2022/11/07 10:05:39 version 1.389, 2023/01/06 02:47:18
Line 178 
Line 178 
         options->disable_forwarding = -1;          options->disable_forwarding = -1;
         options->expose_userauth_info = -1;          options->expose_userauth_info = -1;
         options->required_rsa_size = -1;          options->required_rsa_size = -1;
           options->channel_timeouts = NULL;
           options->num_channel_timeouts = 0;
 }  }
   
 /* Returns 1 if a string option is unset or set to "none" or 0 otherwise. */  /* Returns 1 if a string option is unset or set to "none" or 0 otherwise. */
Line 433 
Line 435 
                         v = NULL; \                          v = NULL; \
                 } \                  } \
         } while(0)          } while(0)
   #define CLEAR_ON_NONE_ARRAY(v, nv, none) \
           do { \
                   if (options->nv == 1 && \
                       strcasecmp(options->v[0], none) == 0) { \
                           free(options->v[0]); \
                           free(options->v); \
                           options->v = NULL; \
                           options->nv = 0; \
                   } \
           } while (0)
         CLEAR_ON_NONE(options->pid_file);          CLEAR_ON_NONE(options->pid_file);
         CLEAR_ON_NONE(options->xauth_location);          CLEAR_ON_NONE(options->xauth_location);
         CLEAR_ON_NONE(options->banner);          CLEAR_ON_NONE(options->banner);
Line 444 
Line 456 
         CLEAR_ON_NONE(options->chroot_directory);          CLEAR_ON_NONE(options->chroot_directory);
         CLEAR_ON_NONE(options->routing_domain);          CLEAR_ON_NONE(options->routing_domain);
         CLEAR_ON_NONE(options->host_key_agent);          CLEAR_ON_NONE(options->host_key_agent);
   
         for (i = 0; i < options->num_host_key_files; i++)          for (i = 0; i < options->num_host_key_files; i++)
                 CLEAR_ON_NONE(options->host_key_files[i]);                  CLEAR_ON_NONE(options->host_key_files[i]);
         for (i = 0; i < options->num_host_cert_files; i++)          for (i = 0; i < options->num_host_cert_files; i++)
                 CLEAR_ON_NONE(options->host_cert_files[i]);                  CLEAR_ON_NONE(options->host_cert_files[i]);
 #undef CLEAR_ON_NONE  
   
         /* Similar handling for AuthenticationMethods=any */          CLEAR_ON_NONE_ARRAY(channel_timeouts, num_channel_timeouts, "none");
         if (options->num_auth_methods == 1 &&          CLEAR_ON_NONE_ARRAY(auth_methods, num_auth_methods, "any");
             strcmp(options->auth_methods[0], "any") == 0) {  #undef CLEAR_ON_NONE
                 free(options->auth_methods[0]);  #undef CLEAR_ON_NONE_ARRAY
                 options->auth_methods[0] = NULL;  
                 options->num_auth_methods = 0;  
         }  
 }  }
   
 /* Keyword tokens. */  /* Keyword tokens. */
Line 492 
Line 501 
         sStreamLocalBindMask, sStreamLocalBindUnlink,          sStreamLocalBindMask, sStreamLocalBindUnlink,
         sAllowStreamLocalForwarding, sFingerprintHash, sDisableForwarding,          sAllowStreamLocalForwarding, sFingerprintHash, sDisableForwarding,
         sExposeAuthInfo, sRDomain, sPubkeyAuthOptions, sSecurityKeyProvider,          sExposeAuthInfo, sRDomain, sPubkeyAuthOptions, sSecurityKeyProvider,
         sRequiredRSASize,          sRequiredRSASize, sChannelTimeout,
         sDeprecated, sIgnore, sUnsupported          sDeprecated, sIgnore, sUnsupported
 } ServerOpCodes;  } ServerOpCodes;
   
Line 637 
Line 646 
         { "casignaturealgorithms", sCASignatureAlgorithms, SSHCFG_ALL },          { "casignaturealgorithms", sCASignatureAlgorithms, SSHCFG_ALL },
         { "securitykeyprovider", sSecurityKeyProvider, SSHCFG_GLOBAL },          { "securitykeyprovider", sSecurityKeyProvider, SSHCFG_GLOBAL },
         { "requiredrsasize", sRequiredRSASize, SSHCFG_ALL },          { "requiredrsasize", sRequiredRSASize, SSHCFG_ALL },
           { "channeltimeout", sChannelTimeout, SSHCFG_ALL },
         { NULL, sBadOption, 0 }          { NULL, sBadOption, 0 }
 };  };
   
Line 893 
Line 903 
             options->num_permitted_listens);              options->num_permitted_listens);
 }  }
   
   /* Parse a ChannelTimeout clause "pattern=interval" */
   static int
   parse_timeout(const char *s, char **typep, u_int *secsp)
   {
           char *cp, *sdup;
           int secs;
   
           if (typep != NULL)
                   *typep = NULL;
           if (secsp != NULL)
                   *secsp = 0;
           if (s == NULL)
                   return -1;
           sdup = xstrdup(s);
   
           if ((cp = strchr(sdup, '=')) == NULL || cp == sdup) {
                   free(sdup);
                   return -1;
           }
           *cp++ = '\0';
           if ((secs = convtime(cp)) < 0) {
                   free(sdup);
                   return -1;
           }
           /* success */
           if (typep != NULL)
                   *typep = xstrdup(sdup);
           if (secsp != NULL)
                   *secsp = (u_int)secs;
           free(sdup);
           return 0;
   }
   
   void
   process_channel_timeouts(struct ssh *ssh, ServerOptions *options)
   {
           u_int i, secs;
           char *type;
   
           debug3_f("setting %u timeouts", options->num_channel_timeouts);
           channel_clear_timeouts(ssh);
           for (i = 0; i < options->num_channel_timeouts; i++) {
                   if (parse_timeout(options->channel_timeouts[i],
                       &type, &secs) != 0) {
                           fatal_f("internal error: bad timeout %s",
                               options->channel_timeouts[i]);
                   }
                   channel_add_timeout(ssh, type, secs);
                   free(type);
           }
   }
   
 struct connection_info *  struct connection_info *
 get_connection_info(struct ssh *ssh, int populate, int use_dns)  get_connection_info(struct ssh *ssh, int populate, int use_dns)
 {  {
Line 2390 
Line 2452 
                 intptr = &options->required_rsa_size;                  intptr = &options->required_rsa_size;
                 goto parse_int;                  goto parse_int;
   
           case sChannelTimeout:
                   uvalue = options->num_channel_timeouts;
                   i = 0;
                   while ((arg = argv_next(&ac, &av)) != NULL) {
                           /* Allow "none" only in first position */
                           if (strcasecmp(arg, "none") == 0) {
                                   if (i > 0 || ac > 0) {
                                           error("%s line %d: keyword %s \"none\" "
                                               "argument must appear alone.",
                                               filename, linenum, keyword);
                                           goto out;
                                   }
                           } else if (parse_timeout(arg, NULL, NULL) != 0) {
                                   fatal("%s line %d: invalid channel timeout %s",
                                       filename, linenum, arg);
                           }
                           if (!*activep || uvalue != 0)
                                   continue;
                           opt_array_append(filename, linenum, keyword,
                               &options->channel_timeouts,
                               &options->num_channel_timeouts, arg);
                   }
                   break;
   
         case sDeprecated:          case sDeprecated:
         case sIgnore:          case sIgnore:
         case sUnsupported:          case sUnsupported:
Line 2757 
Line 2843 
                 printf(" %s",  vals[i]);                  printf(" %s",  vals[i]);
         if (code == sAuthenticationMethods && count == 0)          if (code == sAuthenticationMethods && count == 0)
                 printf(" any");                  printf(" any");
           else if (code == sChannelTimeout && count == 0)
                   printf(" none");
         printf("\n");          printf("\n");
 }  }
   
Line 2916 
Line 3004 
             o->num_auth_methods, o->auth_methods);              o->num_auth_methods, o->auth_methods);
         dump_cfg_strarray_oneline(sLogVerbose,          dump_cfg_strarray_oneline(sLogVerbose,
             o->num_log_verbose, o->log_verbose);              o->num_log_verbose, o->log_verbose);
           dump_cfg_strarray_oneline(sChannelTimeout,
               o->num_channel_timeouts, o->channel_timeouts);
   
         /* other arguments */          /* other arguments */
         for (i = 0; i < o->num_subsystems; i++)          for (i = 0; i < o->num_subsystems; i++)

Legend:
Removed from v.1.388  
changed lines
  Added in v.1.389