|
Lines 68-73
initialize_server_options(ServerOptions
Link Here
|
| 68 |
memset(options, 0, sizeof(*options)); |
68 |
memset(options, 0, sizeof(*options)); |
| 69 |
options->num_ports = 0; |
69 |
options->num_ports = 0; |
| 70 |
options->ports_from_cmdline = 0; |
70 |
options->ports_from_cmdline = 0; |
|
|
71 |
options->queued_listen_addrs = NULL; |
| 72 |
options->num_queued_listens = 0; |
| 71 |
options->listen_addrs = NULL; |
73 |
options->listen_addrs = NULL; |
| 72 |
options->address_family = -1; |
74 |
options->address_family = -1; |
| 73 |
options->num_host_key_files = 0; |
75 |
options->num_host_key_files = 0; |
|
Lines 188-193
fill_default_server_options(ServerOption
Link Here
|
| 188 |
/* No certificates by default */ |
190 |
/* No certificates by default */ |
| 189 |
if (options->num_ports == 0) |
191 |
if (options->num_ports == 0) |
| 190 |
options->ports[options->num_ports++] = SSH_DEFAULT_PORT; |
192 |
options->ports[options->num_ports++] = SSH_DEFAULT_PORT; |
|
|
193 |
if (options->address_family == -1) |
| 194 |
options->address_family = AF_UNSPEC; |
| 191 |
if (options->listen_addrs == NULL) |
195 |
if (options->listen_addrs == NULL) |
| 192 |
add_listen_addr(options, NULL, 0); |
196 |
add_listen_addr(options, NULL, 0); |
| 193 |
if (options->pid_file == NULL) |
197 |
if (options->pid_file == NULL) |
|
Lines 549-558
add_listen_addr(ServerOptions *options,
Link Here
|
| 549 |
{ |
553 |
{ |
| 550 |
u_int i; |
554 |
u_int i; |
| 551 |
|
555 |
|
| 552 |
if (options->num_ports == 0) |
|
|
| 553 |
options->ports[options->num_ports++] = SSH_DEFAULT_PORT; |
| 554 |
if (options->address_family == -1) |
| 555 |
options->address_family = AF_UNSPEC; |
| 556 |
if (port == 0) |
556 |
if (port == 0) |
| 557 |
for (i = 0; i < options->num_ports; i++) |
557 |
for (i = 0; i < options->num_ports; i++) |
| 558 |
add_one_listen_addr(options, addr, options->ports[i]); |
558 |
add_one_listen_addr(options, addr, options->ports[i]); |
|
Lines 582-587
add_one_listen_addr(ServerOptions *optio
Link Here
|
| 582 |
options->listen_addrs = aitop; |
582 |
options->listen_addrs = aitop; |
| 583 |
} |
583 |
} |
| 584 |
|
584 |
|
|
|
585 |
/* |
| 586 |
* Queue a ListenAddress to be processed once we have all of the Ports |
| 587 |
* and AddressFamily options. |
| 588 |
*/ |
| 589 |
static void |
| 590 |
queue_listen_addr(ServerOptions *options, char *addr, int port) |
| 591 |
{ |
| 592 |
options->queued_listen_addrs = xreallocarray( |
| 593 |
options->queued_listen_addrs, options->num_queued_listens + 1, |
| 594 |
sizeof(addr)); |
| 595 |
options->queued_listen_ports = xreallocarray( |
| 596 |
options->queued_listen_ports, options->num_queued_listens + 1, |
| 597 |
sizeof(port)); |
| 598 |
options->queued_listen_addrs[options->num_queued_listens] = |
| 599 |
xstrdup(addr); |
| 600 |
options->queued_listen_ports[options->num_queued_listens] = port; |
| 601 |
options->num_queued_listens++; |
| 602 |
} |
| 603 |
|
| 604 |
/* |
| 605 |
* Process queued (text) ListenAddress entries. |
| 606 |
*/ |
| 607 |
static void |
| 608 |
process_queued_listen_addrs(ServerOptions *options) |
| 609 |
{ |
| 610 |
u_int i; |
| 611 |
|
| 612 |
if (options->num_ports == 0) |
| 613 |
options->ports[options->num_ports++] = SSH_DEFAULT_PORT; |
| 614 |
if (options->address_family == -1) |
| 615 |
options->address_family = AF_UNSPEC; |
| 616 |
|
| 617 |
for (i = 0; i < options->num_queued_listens; i++) { |
| 618 |
add_listen_addr(options, options->queued_listen_addrs[i], |
| 619 |
options->queued_listen_ports[i]); |
| 620 |
free(options->queued_listen_addrs[i]); |
| 621 |
options->queued_listen_addrs[i] = NULL; |
| 622 |
} |
| 623 |
free(options->queued_listen_addrs); |
| 624 |
options->queued_listen_addrs = NULL; |
| 625 |
free(options->queued_listen_ports); |
| 626 |
options->queued_listen_ports = NULL; |
| 627 |
options->num_queued_listens = 0; |
| 628 |
} |
| 629 |
|
| 585 |
struct connection_info * |
630 |
struct connection_info * |
| 586 |
get_connection_info(int populate, int use_dns) |
631 |
get_connection_info(int populate, int use_dns) |
| 587 |
{ |
632 |
{ |
|
Lines 892-900
process_server_config_line(ServerOptions
Link Here
|
| 892 |
/* ignore ports from configfile if cmdline specifies ports */ |
937 |
/* ignore ports from configfile if cmdline specifies ports */ |
| 893 |
if (options->ports_from_cmdline) |
938 |
if (options->ports_from_cmdline) |
| 894 |
return 0; |
939 |
return 0; |
| 895 |
if (options->listen_addrs != NULL) |
|
|
| 896 |
fatal("%s line %d: ports must be specified before " |
| 897 |
"ListenAddress.", filename, linenum); |
| 898 |
if (options->num_ports >= MAX_PORTS) |
940 |
if (options->num_ports >= MAX_PORTS) |
| 899 |
fatal("%s line %d: too many ports.", |
941 |
fatal("%s line %d: too many ports.", |
| 900 |
filename, linenum); |
942 |
filename, linenum); |
|
Lines 946-952
process_server_config_line(ServerOptions
Link Here
|
| 946 |
/* check for bare IPv6 address: no "[]" and 2 or more ":" */ |
988 |
/* check for bare IPv6 address: no "[]" and 2 or more ":" */ |
| 947 |
if (strchr(arg, '[') == NULL && (p = strchr(arg, ':')) != NULL |
989 |
if (strchr(arg, '[') == NULL && (p = strchr(arg, ':')) != NULL |
| 948 |
&& strchr(p+1, ':') != NULL) { |
990 |
&& strchr(p+1, ':') != NULL) { |
| 949 |
add_listen_addr(options, arg, 0); |
991 |
queue_listen_addr(options, arg, 0); |
| 950 |
break; |
992 |
break; |
| 951 |
} |
993 |
} |
| 952 |
p = hpdelim(&arg); |
994 |
p = hpdelim(&arg); |
|
Lines 959-974
process_server_config_line(ServerOptions
Link Here
|
| 959 |
else if ((port = a2port(arg)) <= 0) |
1001 |
else if ((port = a2port(arg)) <= 0) |
| 960 |
fatal("%s line %d: bad port number", filename, linenum); |
1002 |
fatal("%s line %d: bad port number", filename, linenum); |
| 961 |
|
1003 |
|
| 962 |
add_listen_addr(options, p, port); |
1004 |
queue_listen_addr(options, p, port); |
| 963 |
|
1005 |
|
| 964 |
break; |
1006 |
break; |
| 965 |
|
1007 |
|
| 966 |
case sAddressFamily: |
1008 |
case sAddressFamily: |
| 967 |
intptr = &options->address_family; |
1009 |
intptr = &options->address_family; |
| 968 |
multistate_ptr = multistate_addressfamily; |
1010 |
multistate_ptr = multistate_addressfamily; |
| 969 |
if (options->listen_addrs != NULL) |
|
|
| 970 |
fatal("%s line %d: address family must be specified " |
| 971 |
"before ListenAddress.", filename, linenum); |
| 972 |
parse_multistate: |
1011 |
parse_multistate: |
| 973 |
arg = strdelim(&cp); |
1012 |
arg = strdelim(&cp); |
| 974 |
if (!arg || *arg == '\0') |
1013 |
if (!arg || *arg == '\0') |
|
Lines 1903-1908
parse_server_config(ServerOptions *optio
Link Here
|
| 1903 |
if (bad_options > 0) |
1942 |
if (bad_options > 0) |
| 1904 |
fatal("%s: terminating, %d bad configuration options", |
1943 |
fatal("%s: terminating, %d bad configuration options", |
| 1905 |
filename, bad_options); |
1944 |
filename, bad_options); |
|
|
1945 |
process_queued_listen_addrs(options); |
| 1906 |
} |
1946 |
} |
| 1907 |
|
1947 |
|
| 1908 |
static const char * |
1948 |
static const char * |