summaryrefslogtreecommitdiff
path: root/servconf.c
diff options
context:
space:
mode:
Diffstat (limited to 'servconf.c')
-rw-r--r--servconf.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/servconf.c b/servconf.c
index 8e876d1f1..f3d5068c0 100644
--- a/servconf.c
+++ b/servconf.c
@@ -10,7 +10,7 @@
10 */ 10 */
11 11
12#include "includes.h" 12#include "includes.h"
13RCSID("$OpenBSD: servconf.c,v 1.75 2001/04/12 19:15:25 markus Exp $"); 13RCSID("$OpenBSD: servconf.c,v 1.76 2001/04/12 20:09:37 stevesk Exp $");
14 14
15#ifdef KRB4 15#ifdef KRB4
16#include <krb.h> 16#include <krb.h>
@@ -31,8 +31,7 @@ RCSID("$OpenBSD: servconf.c,v 1.75 2001/04/12 19:15:25 markus Exp $");
31#include "kex.h" 31#include "kex.h"
32#include "mac.h" 32#include "mac.h"
33 33
34/* add listen address */ 34void add_listen_addr(ServerOptions *options, char *addr, u_short port);
35void add_listen_addr(ServerOptions *options, char *addr, char *port);
36void add_one_listen_addr(ServerOptions *options, char *addr, u_short port); 35void add_one_listen_addr(ServerOptions *options, char *addr, u_short port);
37 36
38/* AF_UNSPEC or AF_INET or AF_INET6 */ 37/* AF_UNSPEC or AF_INET or AF_INET6 */
@@ -117,7 +116,7 @@ fill_default_server_options(ServerOptions *options)
117 if (options->num_ports == 0) 116 if (options->num_ports == 0)
118 options->ports[options->num_ports++] = SSH_DEFAULT_PORT; 117 options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
119 if (options->listen_addrs == NULL) 118 if (options->listen_addrs == NULL)
120 add_listen_addr(options, NULL, NULL); 119 add_listen_addr(options, NULL, 0);
121 if (options->pid_file == NULL) 120 if (options->pid_file == NULL)
122 options->pid_file = _PATH_SSH_DAEMON_PID_FILE; 121 options->pid_file = _PATH_SSH_DAEMON_PID_FILE;
123 if (options->server_key_bits == -1) 122 if (options->server_key_bits == -1)
@@ -312,21 +311,18 @@ parse_token(const char *cp, const char *filename,
312 return sBadOption; 311 return sBadOption;
313} 312}
314 313
315/*
316 * add listen address
317 */
318void 314void
319add_listen_addr(ServerOptions *options, char *addr, char *port) 315add_listen_addr(ServerOptions *options, char *addr, u_short port)
320{ 316{
321 int i; 317 int i;
322 318
323 if (options->num_ports == 0) 319 if (options->num_ports == 0)
324 options->ports[options->num_ports++] = SSH_DEFAULT_PORT; 320 options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
325 if (port == NULL) 321 if (port == 0)
326 for (i = 0; i < options->num_ports; i++) 322 for (i = 0; i < options->num_ports; i++)
327 add_one_listen_addr(options, addr, options->ports[i]); 323 add_one_listen_addr(options, addr, options->ports[i]);
328 else 324 else
329 add_one_listen_addr(options, addr, atoi(port)); 325 add_one_listen_addr(options, addr, port);
330} 326}
331 327
332void 328void
@@ -400,7 +396,10 @@ read_server_config(ServerOptions *options, const char *filename)
400 if (!arg || *arg == '\0') 396 if (!arg || *arg == '\0')
401 fatal("%s line %d: missing port number.", 397 fatal("%s line %d: missing port number.",
402 filename, linenum); 398 filename, linenum);
403 options->ports[options->num_ports++] = atoi(arg); 399 options->ports[options->num_ports++] = a2port(arg);
400 if (options->ports[options->num_ports-1] == 0)
401 fatal("%s line %d: Badly formatted port number.",
402 filename, linenum);
404 break; 403 break;
405 404
406 case sServerKeyBits: 405 case sServerKeyBits:
@@ -438,20 +437,25 @@ parse_int:
438 memmove(p, p+1, strlen(p+1)+1); 437 memmove(p, p+1, strlen(p+1)+1);
439 } else if (((p = strchr(arg, ':')) == NULL) || 438 } else if (((p = strchr(arg, ':')) == NULL) ||
440 (strchr(p+1, ':') != NULL)) { 439 (strchr(p+1, ':') != NULL)) {
441 add_listen_addr(options, arg, NULL); 440 add_listen_addr(options, arg, 0);
442 break; 441 break;
443 } 442 }
444 if (*p == ':') { 443 if (*p == ':') {
444 u_short port;
445
445 p++; 446 p++;
446 if (*p == '\0') 447 if (*p == '\0')
447 fatal("%s line %d: bad inet addr:port usage.", 448 fatal("%s line %d: bad inet addr:port usage.",
448 filename, linenum); 449 filename, linenum);
449 else { 450 else {
450 *(p-1) = '\0'; 451 *(p-1) = '\0';
451 add_listen_addr(options, arg, p); 452 if ((port = a2port(p)) == 0)
453 fatal("%s line %d: bad port number.",
454 filename, linenum);
455 add_listen_addr(options, arg, port);
452 } 456 }
453 } else if (*p == '\0') 457 } else if (*p == '\0')
454 add_listen_addr(options, arg, NULL); 458 add_listen_addr(options, arg, 0);
455 else 459 else
456 fatal("%s line %d: bad inet addr usage.", 460 fatal("%s line %d: bad inet addr usage.",
457 filename, linenum); 461 filename, linenum);