summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--servconf.c84
2 files changed, 68 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index ad8d9efdc..5c45998c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,14 @@
3 - stevesk@cvs.openbsd.org 2001/04/06 22:12:47 3 - stevesk@cvs.openbsd.org 2001/04/06 22:12:47
4 [hostfile.c] 4 [hostfile.c]
5 unused; typo in comment 5 unused; typo in comment
6 - stevesk@cvs.openbsd.org 2001/04/06 22:25:25
7 [servconf.c]
8 in addition to:
9 ListenAddress host|ipv4_addr|ipv6_addr
10 permit:
11 ListenAddress [host|ipv4_addr|ipv6_addr]:port
12 ListenAddress host|ipv4_addr:port
13 sshd.8 updates coming. ok markus@
6 14
720010407 1520010407
8 - (bal) CVS ID Resync of version.h 16 - (bal) CVS ID Resync of version.h
@@ -4929,4 +4937,4 @@
4929 - Wrote replacements for strlcpy and mkdtemp 4937 - Wrote replacements for strlcpy and mkdtemp
4930 - Released 1.0pre1 4938 - Released 1.0pre1
4931 4939
4932$Id: ChangeLog,v 1.1078 2001/04/07 17:23:43 mouring Exp $ 4940$Id: ChangeLog,v 1.1079 2001/04/07 17:25:48 mouring Exp $
diff --git a/servconf.c b/servconf.c
index 8094d34ca..4d5eb53ae 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.73 2001/04/02 14:20:23 stevesk Exp $"); 13RCSID("$OpenBSD: servconf.c,v 1.74 2001/04/06 22:25:25 stevesk Exp $");
14 14
15#ifdef KRB4 15#ifdef KRB4
16#include <krb.h> 16#include <krb.h>
@@ -32,7 +32,8 @@ RCSID("$OpenBSD: servconf.c,v 1.73 2001/04/02 14:20:23 stevesk Exp $");
32#include "mac.h" 32#include "mac.h"
33 33
34/* add listen address */ 34/* add listen address */
35void add_listen_addr(ServerOptions *options, char *addr); 35void add_listen_addr(ServerOptions *options, char *addr, char *port);
36void add_one_listen_addr(ServerOptions *options, char *addr, u_short port);
36 37
37/* AF_UNSPEC or AF_INET or AF_INET6 */ 38/* AF_UNSPEC or AF_INET or AF_INET6 */
38extern int IPv4or6; 39extern int IPv4or6;
@@ -114,7 +115,7 @@ fill_default_server_options(ServerOptions *options)
114 if (options->num_ports == 0) 115 if (options->num_ports == 0)
115 options->ports[options->num_ports++] = SSH_DEFAULT_PORT; 116 options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
116 if (options->listen_addrs == NULL) 117 if (options->listen_addrs == NULL)
117 add_listen_addr(options, NULL); 118 add_listen_addr(options, NULL, NULL);
118 if (options->pid_file == NULL) 119 if (options->pid_file == NULL)
119 options->pid_file = _PATH_SSH_DAEMON_PID_FILE; 120 options->pid_file = _PATH_SSH_DAEMON_PID_FILE;
120 if (options->server_key_bits == -1) 121 if (options->server_key_bits == -1)
@@ -306,30 +307,39 @@ parse_token(const char *cp, const char *filename,
306 * add listen address 307 * add listen address
307 */ 308 */
308void 309void
309add_listen_addr(ServerOptions *options, char *addr) 310add_listen_addr(ServerOptions *options, char *addr, char *port)
310{ 311{
311 struct addrinfo hints, *ai, *aitop;
312 char strport[NI_MAXSERV];
313 int gaierr;
314 int i; 312 int i;
315 313
316 if (options->num_ports == 0) 314 if (options->num_ports == 0)
317 options->ports[options->num_ports++] = SSH_DEFAULT_PORT; 315 options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
318 for (i = 0; i < options->num_ports; i++) { 316 if (port == NULL)
319 memset(&hints, 0, sizeof(hints)); 317 for (i = 0; i < options->num_ports; i++)
320 hints.ai_family = IPv4or6; 318 add_one_listen_addr(options, addr, options->ports[i]);
321 hints.ai_socktype = SOCK_STREAM; 319 else
322 hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0; 320 add_one_listen_addr(options, addr, atoi(port));
323 snprintf(strport, sizeof strport, "%d", options->ports[i]); 321}
324 if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0) 322
325 fatal("bad addr or host: %s (%s)", 323void
326 addr ? addr : "<NULL>", 324add_one_listen_addr(ServerOptions *options, char *addr, u_short port)
327 gai_strerror(gaierr)); 325{
328 for (ai = aitop; ai->ai_next; ai = ai->ai_next) 326 struct addrinfo hints, *ai, *aitop;
329 ; 327 char strport[NI_MAXSERV];
330 ai->ai_next = options->listen_addrs; 328 int gaierr;
331 options->listen_addrs = aitop; 329
332 } 330 memset(&hints, 0, sizeof(hints));
331 hints.ai_family = IPv4or6;
332 hints.ai_socktype = SOCK_STREAM;
333 hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0;
334 snprintf(strport, sizeof strport, "%d", port);
335 if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
336 fatal("bad addr or host: %s (%s)",
337 addr ? addr : "<NULL>",
338 gai_strerror(gaierr));
339 for (ai = aitop; ai->ai_next; ai = ai->ai_next)
340 ;
341 ai->ai_next = options->listen_addrs;
342 options->listen_addrs = aitop;
333} 343}
334 344
335/* Reads the server configuration file. */ 345/* Reads the server configuration file. */
@@ -339,7 +349,7 @@ read_server_config(ServerOptions *options, const char *filename)
339{ 349{
340 FILE *f; 350 FILE *f;
341 char line[1024]; 351 char line[1024];
342 char *cp, **charptr, *arg; 352 char *cp, **charptr, *arg, *p;
343 int linenum, *intptr, value; 353 int linenum, *intptr, value;
344 int bad_options = 0; 354 int bad_options = 0;
345 ServerOpCodes opcode; 355 ServerOpCodes opcode;
@@ -408,10 +418,34 @@ parse_int:
408 418
409 case sListenAddress: 419 case sListenAddress:
410 arg = strdelim(&cp); 420 arg = strdelim(&cp);
411 if (!arg || *arg == '\0') 421 if (!arg || *arg == '\0' || strncmp(arg, "[]", 2) == 0)
412 fatal("%s line %d: missing inet addr.", 422 fatal("%s line %d: missing inet addr.",
413 filename, linenum); 423 filename, linenum);
414 add_listen_addr(options, arg); 424 if (*arg == '[') {
425 if ((p = strchr(arg, ']')) == NULL)
426 fatal("%s line %d: bad ipv6 inet addr usage.",
427 filename, linenum);
428 arg++;
429 memmove(p, p+1, strlen(p+1)+1);
430 } else if (((p = strchr(arg, ':')) == NULL) ||
431 (strchr(p+1, ':') != NULL)) {
432 add_listen_addr(options, arg, NULL);
433 break;
434 }
435 if (*p == ':') {
436 p++;
437 if (*p == '\0')
438 fatal("%s line %d: bad inet addr:port usage.",
439 filename, linenum);
440 else {
441 *(p-1) = '\0';
442 add_listen_addr(options, arg, p);
443 }
444 } else if (*p == '\0')
445 add_listen_addr(options, arg, NULL);
446 else
447 fatal("%s line %d: bad inet addr usage.",
448 filename, linenum);
415 break; 449 break;
416 450
417 case sHostKeyFile: 451 case sHostKeyFile: