=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/servconf.c,v retrieving revision 1.137.2.3 retrieving revision 1.138 diff -u -r1.137.2.3 -r1.138 --- src/usr.bin/ssh/servconf.c 2005/09/02 03:45:00 1.137.2.3 +++ src/usr.bin/ssh/servconf.c 2004/12/23 23:11:00 1.138 @@ -10,7 +10,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: servconf.c,v 1.137.2.3 2005/09/02 03:45:00 brad Exp $"); +RCSID("$OpenBSD: servconf.c,v 1.138 2004/12/23 23:11:00 djm Exp $"); #include "ssh.h" #include "log.h" @@ -191,7 +191,7 @@ if (options->use_login == -1) options->use_login = 0; if (options->compression == -1) - options->compression = COMP_DELAYED; + options->compression = 1; if (options->allow_tcp_forwarding == -1) options->allow_tcp_forwarding = 1; if (options->gateway_ports == -1) @@ -363,7 +363,7 @@ static void add_listen_addr(ServerOptions *options, char *addr, u_short port) { - u_int i; + int i; if (options->num_ports == 0) options->ports[options->num_ports++] = SSH_DEFAULT_PORT; @@ -403,10 +403,8 @@ const char *filename, int linenum) { char *cp, **charptr, *arg, *p; - int *intptr, value, n; + int *intptr, value, i, n; ServerOpCodes opcode; - u_short port; - u_int i; cp = line; arg = strdelim(&cp); @@ -473,34 +471,43 @@ case sListenAddress: arg = strdelim(&cp); - if (arg == NULL || *arg == '\0') - fatal("%s line %d: missing address", + if (!arg || *arg == '\0' || strncmp(arg, "[]", 2) == 0) + fatal("%s line %d: missing inet addr.", filename, linenum); - /* check for bare IPv6 address: no "[]" and 2 or more ":" */ - if (strchr(arg, '[') == NULL && (p = strchr(arg, ':')) != NULL - && strchr(p+1, ':') != NULL) { + if (*arg == '[') { + if ((p = strchr(arg, ']')) == NULL) + fatal("%s line %d: bad ipv6 inet addr usage.", + filename, linenum); + arg++; + memmove(p, p+1, strlen(p+1)+1); + } else if (((p = strchr(arg, ':')) == NULL) || + (strchr(p+1, ':') != NULL)) { add_listen_addr(options, arg, 0); break; } - p = hpdelim(&arg); - if (p == NULL) - fatal("%s line %d: bad address:port usage", - filename, linenum); - p = cleanhostname(p); - if (arg == NULL) - port = 0; - else if ((port = a2port(arg)) == 0) - fatal("%s line %d: bad port number", filename, linenum); + if (*p == ':') { + u_short port; - add_listen_addr(options, p, port); - + p++; + if (*p == '\0') + fatal("%s line %d: bad inet addr:port usage.", + filename, linenum); + else { + *(p-1) = '\0'; + if ((port = a2port(p)) == 0) + fatal("%s line %d: bad port number.", + filename, linenum); + add_listen_addr(options, arg, port); + } + } else if (*p == '\0') + add_listen_addr(options, arg, 0); + else + fatal("%s line %d: bad inet addr usage.", + filename, linenum); break; case sAddressFamily: arg = strdelim(&cp); - if (!arg || *arg == '\0') - fatal("%s line %d: missing address family.", - filename, linenum); intptr = &options->address_family; if (options->listen_addrs != NULL) fatal("%s line %d: address family must be specified before " @@ -690,43 +697,11 @@ case sCompression: intptr = &options->compression; - arg = strdelim(&cp); - if (!arg || *arg == '\0') - fatal("%s line %d: missing yes/no/delayed " - "argument.", filename, linenum); - value = 0; /* silence compiler */ - if (strcmp(arg, "delayed") == 0) - value = COMP_DELAYED; - else if (strcmp(arg, "yes") == 0) - value = COMP_ZLIB; - else if (strcmp(arg, "no") == 0) - value = COMP_NONE; - else - fatal("%s line %d: Bad yes/no/delayed " - "argument: %s", filename, linenum, arg); - if (*intptr == -1) - *intptr = value; - break; + goto parse_flag; case sGatewayPorts: intptr = &options->gateway_ports; - arg = strdelim(&cp); - if (!arg || *arg == '\0') - fatal("%s line %d: missing yes/no/clientspecified " - "argument.", filename, linenum); - value = 0; /* silence compiler */ - if (strcmp(arg, "clientspecified") == 0) - value = 2; - else if (strcmp(arg, "yes") == 0) - value = 1; - else if (strcmp(arg, "no") == 0) - value = 0; - else - fatal("%s line %d: Bad yes/no/clientspecified " - "argument: %s", filename, linenum, arg); - if (*intptr == -1) - *intptr = value; - break; + goto parse_flag; case sUseDNS: intptr = &options->use_dns; @@ -986,7 +961,7 @@ obuf = cbuf = xstrdup(buffer_ptr(conf)); linenum = 1; - while ((cp = strsep(&cbuf, "\n")) != NULL) { + while((cp = strsep(&cbuf, "\n")) != NULL) { if (process_server_config_line(options, cp, filename, linenum++) != 0) bad_options++;