diff options
author | Darren Tucker <dtucker@zip.com.au> | 2005-01-20 10:57:56 +1100 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2005-01-20 10:57:56 +1100 |
commit | 0f3832322230ebc4b0fe5a2aca5cf9aaa8b0c3c1 (patch) | |
tree | 636c57585769866a43d63c1f15e92930b07b4007 /servconf.c | |
parent | 7cfeecf67008d5135718806fab6bda7f353e5f59 (diff) |
- djm@cvs.openbsd.org 2004/12/23 23:11:00
[servconf.c servconf.h sshd.c sshd_config sshd_config.5]
bz #898: support AddressFamily in sshd_config. from
peak@argo.troja.mff.cuni.cz; ok deraadt@
Diffstat (limited to 'servconf.c')
-rw-r--r-- | servconf.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/servconf.c b/servconf.c index fae3c658e..541a9c85b 100644 --- a/servconf.c +++ b/servconf.c | |||
@@ -10,7 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include "includes.h" | 12 | #include "includes.h" |
13 | RCSID("$OpenBSD: servconf.c,v 1.137 2004/08/13 11:09:24 dtucker Exp $"); | 13 | RCSID("$OpenBSD: servconf.c,v 1.138 2004/12/23 23:11:00 djm Exp $"); |
14 | 14 | ||
15 | #include "ssh.h" | 15 | #include "ssh.h" |
16 | #include "log.h" | 16 | #include "log.h" |
@@ -26,8 +26,6 @@ RCSID("$OpenBSD: servconf.c,v 1.137 2004/08/13 11:09:24 dtucker Exp $"); | |||
26 | static void add_listen_addr(ServerOptions *, char *, u_short); | 26 | static void add_listen_addr(ServerOptions *, char *, u_short); |
27 | static void add_one_listen_addr(ServerOptions *, char *, u_short); | 27 | static void add_one_listen_addr(ServerOptions *, char *, u_short); |
28 | 28 | ||
29 | /* AF_UNSPEC or AF_INET or AF_INET6 */ | ||
30 | extern int IPv4or6; | ||
31 | /* Use of privilege separation or not */ | 29 | /* Use of privilege separation or not */ |
32 | extern int use_privsep; | 30 | extern int use_privsep; |
33 | 31 | ||
@@ -45,6 +43,7 @@ initialize_server_options(ServerOptions *options) | |||
45 | options->num_ports = 0; | 43 | options->num_ports = 0; |
46 | options->ports_from_cmdline = 0; | 44 | options->ports_from_cmdline = 0; |
47 | options->listen_addrs = NULL; | 45 | options->listen_addrs = NULL; |
46 | options->address_family = -1; | ||
48 | options->num_host_key_files = 0; | 47 | options->num_host_key_files = 0; |
49 | options->pid_file = NULL; | 48 | options->pid_file = NULL; |
50 | options->server_key_bits = -1; | 49 | options->server_key_bits = -1; |
@@ -258,7 +257,8 @@ typedef enum { | |||
258 | sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup, | 257 | sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup, |
259 | sKerberosGetAFSToken, | 258 | sKerberosGetAFSToken, |
260 | sKerberosTgtPassing, sChallengeResponseAuthentication, | 259 | sKerberosTgtPassing, sChallengeResponseAuthentication, |
261 | sPasswordAuthentication, sKbdInteractiveAuthentication, sListenAddress, | 260 | sPasswordAuthentication, sKbdInteractiveAuthentication, |
261 | sListenAddress, sAddressFamily, | ||
262 | sPrintMotd, sPrintLastLog, sIgnoreRhosts, | 262 | sPrintMotd, sPrintLastLog, sIgnoreRhosts, |
263 | sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost, | 263 | sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost, |
264 | sStrictModes, sEmptyPasswd, sTCPKeepAlive, | 264 | sStrictModes, sEmptyPasswd, sTCPKeepAlive, |
@@ -335,6 +335,7 @@ static struct { | |||
335 | { "skeyauthentication", sChallengeResponseAuthentication }, /* alias */ | 335 | { "skeyauthentication", sChallengeResponseAuthentication }, /* alias */ |
336 | { "checkmail", sDeprecated }, | 336 | { "checkmail", sDeprecated }, |
337 | { "listenaddress", sListenAddress }, | 337 | { "listenaddress", sListenAddress }, |
338 | { "addressfamily", sAddressFamily }, | ||
338 | { "printmotd", sPrintMotd }, | 339 | { "printmotd", sPrintMotd }, |
339 | { "printlastlog", sPrintLastLog }, | 340 | { "printlastlog", sPrintLastLog }, |
340 | { "ignorerhosts", sIgnoreRhosts }, | 341 | { "ignorerhosts", sIgnoreRhosts }, |
@@ -401,6 +402,8 @@ add_listen_addr(ServerOptions *options, char *addr, u_short port) | |||
401 | 402 | ||
402 | if (options->num_ports == 0) | 403 | if (options->num_ports == 0) |
403 | options->ports[options->num_ports++] = SSH_DEFAULT_PORT; | 404 | options->ports[options->num_ports++] = SSH_DEFAULT_PORT; |
405 | if (options->address_family == -1) | ||
406 | options->address_family = AF_UNSPEC; | ||
404 | if (port == 0) | 407 | if (port == 0) |
405 | for (i = 0; i < options->num_ports; i++) | 408 | for (i = 0; i < options->num_ports; i++) |
406 | add_one_listen_addr(options, addr, options->ports[i]); | 409 | add_one_listen_addr(options, addr, options->ports[i]); |
@@ -416,7 +419,7 @@ add_one_listen_addr(ServerOptions *options, char *addr, u_short port) | |||
416 | int gaierr; | 419 | int gaierr; |
417 | 420 | ||
418 | memset(&hints, 0, sizeof(hints)); | 421 | memset(&hints, 0, sizeof(hints)); |
419 | hints.ai_family = IPv4or6; | 422 | hints.ai_family = options->address_family; |
420 | hints.ai_socktype = SOCK_STREAM; | 423 | hints.ai_socktype = SOCK_STREAM; |
421 | hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0; | 424 | hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0; |
422 | snprintf(strport, sizeof strport, "%u", port); | 425 | snprintf(strport, sizeof strport, "%u", port); |
@@ -544,6 +547,25 @@ parse_time: | |||
544 | filename, linenum); | 547 | filename, linenum); |
545 | break; | 548 | break; |
546 | 549 | ||
550 | case sAddressFamily: | ||
551 | arg = strdelim(&cp); | ||
552 | intptr = &options->address_family; | ||
553 | if (options->listen_addrs != NULL) | ||
554 | fatal("%s line %d: address family must be specified before " | ||
555 | "ListenAddress.", filename, linenum); | ||
556 | if (strcasecmp(arg, "inet") == 0) | ||
557 | value = AF_INET; | ||
558 | else if (strcasecmp(arg, "inet6") == 0) | ||
559 | value = AF_INET6; | ||
560 | else if (strcasecmp(arg, "any") == 0) | ||
561 | value = AF_UNSPEC; | ||
562 | else | ||
563 | fatal("%s line %d: unsupported address family \"%s\".", | ||
564 | filename, linenum, arg); | ||
565 | if (*intptr == -1) | ||
566 | *intptr = value; | ||
567 | break; | ||
568 | |||
547 | case sHostKeyFile: | 569 | case sHostKeyFile: |
548 | intptr = &options->num_host_key_files; | 570 | intptr = &options->num_host_key_files; |
549 | if (*intptr >= MAX_HOSTKEYS) | 571 | if (*intptr >= MAX_HOSTKEYS) |