version 1.265, 2015/04/27 21:42:48 |
version 1.266, 2015/04/29 03:48:56 |
|
|
memset(options, 0, sizeof(*options)); |
memset(options, 0, sizeof(*options)); |
options->num_ports = 0; |
options->num_ports = 0; |
options->ports_from_cmdline = 0; |
options->ports_from_cmdline = 0; |
|
options->queued_listen_addrs = NULL; |
|
options->num_queued_listens = 0; |
options->listen_addrs = NULL; |
options->listen_addrs = NULL; |
options->address_family = -1; |
options->address_family = -1; |
options->num_host_key_files = 0; |
options->num_host_key_files = 0; |
|
|
/* No certificates by default */ |
/* No certificates by default */ |
if (options->num_ports == 0) |
if (options->num_ports == 0) |
options->ports[options->num_ports++] = SSH_DEFAULT_PORT; |
options->ports[options->num_ports++] = SSH_DEFAULT_PORT; |
|
if (options->address_family == -1) |
|
options->address_family = AF_UNSPEC; |
if (options->listen_addrs == NULL) |
if (options->listen_addrs == NULL) |
add_listen_addr(options, NULL, 0); |
add_listen_addr(options, NULL, 0); |
if (options->pid_file == NULL) |
if (options->pid_file == NULL) |
|
|
{ |
{ |
u_int i; |
u_int i; |
|
|
if (options->num_ports == 0) |
|
options->ports[options->num_ports++] = SSH_DEFAULT_PORT; |
|
if (options->address_family == -1) |
|
options->address_family = AF_UNSPEC; |
|
if (port == 0) |
if (port == 0) |
for (i = 0; i < options->num_ports; i++) |
for (i = 0; i < options->num_ports; i++) |
add_one_listen_addr(options, addr, options->ports[i]); |
add_one_listen_addr(options, addr, options->ports[i]); |
|
|
options->listen_addrs = aitop; |
options->listen_addrs = aitop; |
} |
} |
|
|
|
/* |
|
* Queue a ListenAddress to be processed once we have all of the Ports |
|
* and AddressFamily options. |
|
*/ |
|
static void |
|
queue_listen_addr(ServerOptions *options, char *addr, int port) |
|
{ |
|
options->queued_listen_addrs = xreallocarray( |
|
options->queued_listen_addrs, options->num_queued_listens + 1, |
|
sizeof(addr)); |
|
options->queued_listen_ports = xreallocarray( |
|
options->queued_listen_ports, options->num_queued_listens + 1, |
|
sizeof(port)); |
|
options->queued_listen_addrs[options->num_queued_listens] = |
|
xstrdup(addr); |
|
options->queued_listen_ports[options->num_queued_listens] = port; |
|
options->num_queued_listens++; |
|
} |
|
|
|
/* |
|
* Process queued (text) ListenAddress entries. |
|
*/ |
|
static void |
|
process_queued_listen_addrs(ServerOptions *options) |
|
{ |
|
u_int i; |
|
|
|
if (options->num_ports == 0) |
|
options->ports[options->num_ports++] = SSH_DEFAULT_PORT; |
|
if (options->address_family == -1) |
|
options->address_family = AF_UNSPEC; |
|
|
|
for (i = 0; i < options->num_queued_listens; i++) { |
|
add_listen_addr(options, options->queued_listen_addrs[i], |
|
options->queued_listen_ports[i]); |
|
free(options->queued_listen_addrs[i]); |
|
options->queued_listen_addrs[i] = NULL; |
|
} |
|
free(options->queued_listen_addrs); |
|
options->queued_listen_addrs = NULL; |
|
free(options->queued_listen_ports); |
|
options->queued_listen_ports = NULL; |
|
options->num_queued_listens = 0; |
|
} |
|
|
struct connection_info * |
struct connection_info * |
get_connection_info(int populate, int use_dns) |
get_connection_info(int populate, int use_dns) |
{ |
{ |
|
|
/* ignore ports from configfile if cmdline specifies ports */ |
/* ignore ports from configfile if cmdline specifies ports */ |
if (options->ports_from_cmdline) |
if (options->ports_from_cmdline) |
return 0; |
return 0; |
if (options->listen_addrs != NULL) |
|
fatal("%s line %d: ports must be specified before " |
|
"ListenAddress.", filename, linenum); |
|
if (options->num_ports >= MAX_PORTS) |
if (options->num_ports >= MAX_PORTS) |
fatal("%s line %d: too many ports.", |
fatal("%s line %d: too many ports.", |
filename, linenum); |
filename, linenum); |
|
|
/* check for bare IPv6 address: no "[]" and 2 or more ":" */ |
/* check for bare IPv6 address: no "[]" and 2 or more ":" */ |
if (strchr(arg, '[') == NULL && (p = strchr(arg, ':')) != NULL |
if (strchr(arg, '[') == NULL && (p = strchr(arg, ':')) != NULL |
&& strchr(p+1, ':') != NULL) { |
&& strchr(p+1, ':') != NULL) { |
add_listen_addr(options, arg, 0); |
queue_listen_addr(options, arg, 0); |
break; |
break; |
} |
} |
p = hpdelim(&arg); |
p = hpdelim(&arg); |
|
|
else if ((port = a2port(arg)) <= 0) |
else if ((port = a2port(arg)) <= 0) |
fatal("%s line %d: bad port number", filename, linenum); |
fatal("%s line %d: bad port number", filename, linenum); |
|
|
add_listen_addr(options, p, port); |
queue_listen_addr(options, p, port); |
|
|
break; |
break; |
|
|
case sAddressFamily: |
case sAddressFamily: |
intptr = &options->address_family; |
intptr = &options->address_family; |
multistate_ptr = multistate_addressfamily; |
multistate_ptr = multistate_addressfamily; |
if (options->listen_addrs != NULL) |
|
fatal("%s line %d: address family must be specified " |
|
"before ListenAddress.", filename, linenum); |
|
parse_multistate: |
parse_multistate: |
arg = strdelim(&cp); |
arg = strdelim(&cp); |
if (!arg || *arg == '\0') |
if (!arg || *arg == '\0') |
|
|
if (bad_options > 0) |
if (bad_options > 0) |
fatal("%s: terminating, %d bad configuration options", |
fatal("%s: terminating, %d bad configuration options", |
filename, bad_options); |
filename, bad_options); |
|
process_queued_listen_addrs(options); |
} |
} |
|
|
static const char * |
static const char * |