|
Lines 58-65
Link Here
|
| 58 |
#include "myproposal.h" |
58 |
#include "myproposal.h" |
| 59 |
#include "digest.h" |
59 |
#include "digest.h" |
| 60 |
|
60 |
|
| 61 |
static void add_listen_addr(ServerOptions *, char *, int); |
61 |
static void add_listen_addr(ServerOptions *, char *, int, char *); |
| 62 |
static void add_one_listen_addr(ServerOptions *, char *, int); |
62 |
static void add_one_listen_addr(ServerOptions *, char *, int, char *); |
| 63 |
|
63 |
|
| 64 |
/* Use of privilege separation or not */ |
64 |
/* Use of privilege separation or not */ |
| 65 |
extern int use_privsep; |
65 |
extern int use_privsep; |
|
Lines 79-86
initialize_server_options(ServerOptions *options)
Link Here
|
| 79 |
options->num_ports = 0; |
79 |
options->num_ports = 0; |
| 80 |
options->ports_from_cmdline = 0; |
80 |
options->ports_from_cmdline = 0; |
| 81 |
options->queued_listen_addrs = NULL; |
81 |
options->queued_listen_addrs = NULL; |
|
|
82 |
options->queued_listen_domains = NULL; |
| 82 |
options->num_queued_listens = 0; |
83 |
options->num_queued_listens = 0; |
| 83 |
options->listen_addrs = NULL; |
84 |
options->listen_addrs = NULL; |
|
|
85 |
options->num_listen_addrs = 0; |
| 84 |
options->address_family = -1; |
86 |
options->address_family = -1; |
| 85 |
options->num_host_key_files = 0; |
87 |
options->num_host_key_files = 0; |
| 86 |
options->num_host_cert_files = 0; |
88 |
options->num_host_cert_files = 0; |
|
Lines 165-170
initialize_server_options(ServerOptions *options)
Link Here
|
| 165 |
options->fingerprint_hash = -1; |
167 |
options->fingerprint_hash = -1; |
| 166 |
options->disable_forwarding = -1; |
168 |
options->disable_forwarding = -1; |
| 167 |
options->expose_userauth_info = -1; |
169 |
options->expose_userauth_info = -1; |
|
|
170 |
options->bind_device = NULL; |
| 168 |
} |
171 |
} |
| 169 |
|
172 |
|
| 170 |
/* Returns 1 if a string option is unset or set to "none" or 0 otherwise. */ |
173 |
/* Returns 1 if a string option is unset or set to "none" or 0 otherwise. */ |
|
Lines 217-223
fill_default_server_options(ServerOptions *options)
Link Here
|
| 217 |
if (options->address_family == -1) |
220 |
if (options->address_family == -1) |
| 218 |
options->address_family = AF_UNSPEC; |
221 |
options->address_family = AF_UNSPEC; |
| 219 |
if (options->listen_addrs == NULL) |
222 |
if (options->listen_addrs == NULL) |
| 220 |
add_listen_addr(options, NULL, 0); |
223 |
add_listen_addr(options, NULL, 0, NULL); |
| 221 |
if (options->pid_file == NULL) |
224 |
if (options->pid_file == NULL) |
| 222 |
options->pid_file = xstrdup(_PATH_SSH_DAEMON_PID_FILE); |
225 |
options->pid_file = xstrdup(_PATH_SSH_DAEMON_PID_FILE); |
| 223 |
if (options->login_grace_time == -1) |
226 |
if (options->login_grace_time == -1) |
|
Lines 396-402
typedef enum {
Link Here
|
| 396 |
sKerberosGetAFSToken, |
399 |
sKerberosGetAFSToken, |
| 397 |
sKerberosTgtPassing, sChallengeResponseAuthentication, |
400 |
sKerberosTgtPassing, sChallengeResponseAuthentication, |
| 398 |
sPasswordAuthentication, sKbdInteractiveAuthentication, |
401 |
sPasswordAuthentication, sKbdInteractiveAuthentication, |
| 399 |
sListenAddress, sAddressFamily, |
402 |
sListenAddress, sAddressFamily, sBindDevice, |
| 400 |
sPrintMotd, sPrintLastLog, sIgnoreRhosts, |
403 |
sPrintMotd, sPrintLastLog, sIgnoreRhosts, |
| 401 |
sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost, |
404 |
sX11Forwarding, sX11DisplayOffset, sX11UseLocalhost, |
| 402 |
sPermitTTY, sStrictModes, sEmptyPasswd, sTCPKeepAlive, |
405 |
sPermitTTY, sStrictModes, sEmptyPasswd, sTCPKeepAlive, |
|
Lines 566-571
static struct {
Link Here
|
| 566 |
{ "fingerprinthash", sFingerprintHash, SSHCFG_GLOBAL }, |
569 |
{ "fingerprinthash", sFingerprintHash, SSHCFG_GLOBAL }, |
| 567 |
{ "disableforwarding", sDisableForwarding, SSHCFG_ALL }, |
570 |
{ "disableforwarding", sDisableForwarding, SSHCFG_ALL }, |
| 568 |
{ "exposeauthinfo", sExposeAuthInfo, SSHCFG_ALL }, |
571 |
{ "exposeauthinfo", sExposeAuthInfo, SSHCFG_ALL }, |
|
|
572 |
{ "binddevice", sBindDevice }, |
| 569 |
{ NULL, sBadOption, 0 } |
573 |
{ NULL, sBadOption, 0 } |
| 570 |
}; |
574 |
}; |
| 571 |
|
575 |
|
|
Lines 619-639
derelativise_path(const char *path)
Link Here
|
| 619 |
} |
623 |
} |
| 620 |
|
624 |
|
| 621 |
static void |
625 |
static void |
| 622 |
add_listen_addr(ServerOptions *options, char *addr, int port) |
626 |
add_listen_addr(ServerOptions *options, char *addr, int port, char *domain) |
| 623 |
{ |
627 |
{ |
| 624 |
u_int i; |
628 |
u_int i; |
| 625 |
|
629 |
|
| 626 |
if (port == 0) |
630 |
if (port == 0) |
| 627 |
for (i = 0; i < options->num_ports; i++) |
631 |
for (i = 0; i < options->num_ports; i++) |
| 628 |
add_one_listen_addr(options, addr, options->ports[i]); |
632 |
add_one_listen_addr(options, addr, options->ports[i], |
|
|
633 |
domain); |
| 629 |
else |
634 |
else |
| 630 |
add_one_listen_addr(options, addr, port); |
635 |
add_one_listen_addr(options, addr, port, domain); |
| 631 |
} |
636 |
} |
| 632 |
|
637 |
|
| 633 |
static void |
638 |
static void |
| 634 |
add_one_listen_addr(ServerOptions *options, char *addr, int port) |
639 |
add_one_listen_addr(ServerOptions *options, char *addr, int port, char *domain) |
| 635 |
{ |
640 |
{ |
| 636 |
struct addrinfo hints, *ai, *aitop; |
641 |
struct addrinfo hints, *aitop; |
| 637 |
char strport[NI_MAXSERV]; |
642 |
char strport[NI_MAXSERV]; |
| 638 |
int gaierr; |
643 |
int gaierr; |
| 639 |
|
644 |
|
|
Lines 646-655
add_one_listen_addr(ServerOptions *options, char *addr, int port)
Link Here
|
| 646 |
fatal("bad addr or host: %s (%s)", |
651 |
fatal("bad addr or host: %s (%s)", |
| 647 |
addr ? addr : "<NULL>", |
652 |
addr ? addr : "<NULL>", |
| 648 |
ssh_gai_strerror(gaierr)); |
653 |
ssh_gai_strerror(gaierr)); |
| 649 |
for (ai = aitop; ai->ai_next; ai = ai->ai_next) |
654 |
|
| 650 |
; |
655 |
options->listen_addrs = xreallocarray( |
| 651 |
ai->ai_next = options->listen_addrs; |
656 |
options->listen_addrs, options->num_listen_addrs + 1, |
| 652 |
options->listen_addrs = aitop; |
657 |
sizeof(struct listen_address)); |
|
|
658 |
options->listen_addrs[options->num_listen_addrs].addrs = aitop; |
| 659 |
options->listen_addrs[options->num_listen_addrs].domain = |
| 660 |
domain ? xstrdup(domain) : NULL; |
| 661 |
options->num_listen_addrs++; |
| 653 |
} |
662 |
} |
| 654 |
|
663 |
|
| 655 |
/* |
664 |
/* |
|
Lines 657-663
add_one_listen_addr(ServerOptions *options, char *addr, int port)
Link Here
|
| 657 |
* and AddressFamily options. |
666 |
* and AddressFamily options. |
| 658 |
*/ |
667 |
*/ |
| 659 |
static void |
668 |
static void |
| 660 |
queue_listen_addr(ServerOptions *options, char *addr, int port) |
669 |
queue_listen_addr(ServerOptions *options, char *addr, int port, char *domain) |
| 661 |
{ |
670 |
{ |
| 662 |
options->queued_listen_addrs = xreallocarray( |
671 |
options->queued_listen_addrs = xreallocarray( |
| 663 |
options->queued_listen_addrs, options->num_queued_listens + 1, |
672 |
options->queued_listen_addrs, options->num_queued_listens + 1, |
|
Lines 665-673
queue_listen_addr(ServerOptions *options, char *addr, int port)
Link Here
|
| 665 |
options->queued_listen_ports = xreallocarray( |
674 |
options->queued_listen_ports = xreallocarray( |
| 666 |
options->queued_listen_ports, options->num_queued_listens + 1, |
675 |
options->queued_listen_ports, options->num_queued_listens + 1, |
| 667 |
sizeof(port)); |
676 |
sizeof(port)); |
|
|
677 |
options->queued_listen_domains = xreallocarray( |
| 678 |
options->queued_listen_domains, options->num_queued_listens + 1, |
| 679 |
sizeof(domain)); |
| 668 |
options->queued_listen_addrs[options->num_queued_listens] = |
680 |
options->queued_listen_addrs[options->num_queued_listens] = |
| 669 |
xstrdup(addr); |
681 |
xstrdup(addr); |
| 670 |
options->queued_listen_ports[options->num_queued_listens] = port; |
682 |
options->queued_listen_ports[options->num_queued_listens] = port; |
|
|
683 |
options->queued_listen_domains[options->num_queued_listens] = |
| 684 |
domain ? xstrdup(domain) : NULL; |
| 671 |
options->num_queued_listens++; |
685 |
options->num_queued_listens++; |
| 672 |
} |
686 |
} |
| 673 |
|
687 |
|
|
Lines 686-699
process_queued_listen_addrs(ServerOptions *options)
Link Here
|
| 686 |
|
700 |
|
| 687 |
for (i = 0; i < options->num_queued_listens; i++) { |
701 |
for (i = 0; i < options->num_queued_listens; i++) { |
| 688 |
add_listen_addr(options, options->queued_listen_addrs[i], |
702 |
add_listen_addr(options, options->queued_listen_addrs[i], |
| 689 |
options->queued_listen_ports[i]); |
703 |
options->queued_listen_ports[i], |
|
|
704 |
options->queued_listen_domains[i]); |
| 690 |
free(options->queued_listen_addrs[i]); |
705 |
free(options->queued_listen_addrs[i]); |
| 691 |
options->queued_listen_addrs[i] = NULL; |
706 |
options->queued_listen_addrs[i] = NULL; |
|
|
707 |
free(options->queued_listen_domains[i]); |
| 708 |
options->queued_listen_domains[i] = NULL; |
| 692 |
} |
709 |
} |
| 693 |
free(options->queued_listen_addrs); |
710 |
free(options->queued_listen_addrs); |
| 694 |
options->queued_listen_addrs = NULL; |
711 |
options->queued_listen_addrs = NULL; |
| 695 |
free(options->queued_listen_ports); |
712 |
free(options->queued_listen_ports); |
| 696 |
options->queued_listen_ports = NULL; |
713 |
options->queued_listen_ports = NULL; |
|
|
714 |
free(options->queued_listen_domains); |
| 715 |
options->queued_listen_domains = NULL; |
| 697 |
options->num_queued_listens = 0; |
716 |
options->num_queued_listens = 0; |
| 698 |
} |
717 |
} |
| 699 |
|
718 |
|
|
Lines 992-998
process_server_config_line(ServerOptions *options, char *line,
Link Here
|
| 992 |
const char *filename, int linenum, int *activep, |
1011 |
const char *filename, int linenum, int *activep, |
| 993 |
struct connection_info *connectinfo) |
1012 |
struct connection_info *connectinfo) |
| 994 |
{ |
1013 |
{ |
| 995 |
char *cp, **charptr, *arg, *arg2, *p; |
1014 |
char *cp, **charptr, *arg, *arg2, *p, *domain; |
| 996 |
int cmdline = 0, *intptr, value, value2, n, port; |
1015 |
int cmdline = 0, *intptr, value, value2, n, port; |
| 997 |
SyslogFacility *log_facility_ptr; |
1016 |
SyslogFacility *log_facility_ptr; |
| 998 |
LogLevel *log_level_ptr; |
1017 |
LogLevel *log_level_ptr; |
|
Lines 1088-1095
process_server_config_line(ServerOptions *options, char *line,
Link Here
|
| 1088 |
/* check for bare IPv6 address: no "[]" and 2 or more ":" */ |
1107 |
/* check for bare IPv6 address: no "[]" and 2 or more ":" */ |
| 1089 |
if (strchr(arg, '[') == NULL && (p = strchr(arg, ':')) != NULL |
1108 |
if (strchr(arg, '[') == NULL && (p = strchr(arg, ':')) != NULL |
| 1090 |
&& strchr(p+1, ':') != NULL) { |
1109 |
&& strchr(p+1, ':') != NULL) { |
| 1091 |
queue_listen_addr(options, arg, 0); |
1110 |
port = 0; |
| 1092 |
break; |
1111 |
p = arg; |
|
|
1112 |
goto parse_domain; |
| 1093 |
} |
1113 |
} |
| 1094 |
p = hpdelim(&arg); |
1114 |
p = hpdelim(&arg); |
| 1095 |
if (p == NULL) |
1115 |
if (p == NULL) |
|
Lines 1101-1107
process_server_config_line(ServerOptions *options, char *line,
Link Here
|
| 1101 |
else if ((port = a2port(arg)) <= 0) |
1121 |
else if ((port = a2port(arg)) <= 0) |
| 1102 |
fatal("%s line %d: bad port number", filename, linenum); |
1122 |
fatal("%s line %d: bad port number", filename, linenum); |
| 1103 |
|
1123 |
|
| 1104 |
queue_listen_addr(options, p, port); |
1124 |
parse_domain: |
|
|
1125 |
domain = NULL; |
| 1126 |
arg = strdelim(&cp); |
| 1127 |
if (arg && !strcmp(arg, "domain")) { |
| 1128 |
arg = strdelim(&cp); |
| 1129 |
if (arg != NULL && *arg != '\0') |
| 1130 |
domain = arg; |
| 1131 |
} |
| 1132 |
|
| 1133 |
queue_listen_addr(options, p, port, domain); |
| 1105 |
|
1134 |
|
| 1106 |
break; |
1135 |
break; |
| 1107 |
|
1136 |
|
|
Lines 1879-1884
process_server_config_line(ServerOptions *options, char *line,
Link Here
|
| 1879 |
options->fingerprint_hash = value; |
1908 |
options->fingerprint_hash = value; |
| 1880 |
break; |
1909 |
break; |
| 1881 |
|
1910 |
|
|
|
1911 |
case sBindDevice: |
| 1912 |
arg = strdelim(&cp); |
| 1913 |
if (!arg || *arg == '\0') |
| 1914 |
fatal("%s line %d: Missing argument.", filename, linenum); |
| 1915 |
if (options->bind_device == NULL) |
| 1916 |
options->bind_device = xstrdup(arg); |
| 1917 |
break; |
| 1918 |
|
| 1882 |
case sExposeAuthInfo: |
1919 |
case sExposeAuthInfo: |
| 1883 |
intptr = &options->expose_userauth_info; |
1920 |
intptr = &options->expose_userauth_info; |
| 1884 |
goto parse_flag; |
1921 |
goto parse_flag; |
|
Lines 2238-2275
dump_config(ServerOptions *o)
Link Here
|
| 2238 |
int ret; |
2275 |
int ret; |
| 2239 |
struct addrinfo *ai; |
2276 |
struct addrinfo *ai; |
| 2240 |
char addr[NI_MAXHOST], port[NI_MAXSERV], *s = NULL; |
2277 |
char addr[NI_MAXHOST], port[NI_MAXSERV], *s = NULL; |
| 2241 |
char *laddr1 = xstrdup(""), *laddr2 = NULL; |
2278 |
char *laddr = xstrdup(""); |
| 2242 |
|
2279 |
|
| 2243 |
/* these are usually at the top of the config */ |
2280 |
/* these are usually at the top of the config */ |
| 2244 |
for (i = 0; i < o->num_ports; i++) |
2281 |
for (i = 0; i < o->num_ports; i++) |
| 2245 |
printf("port %d\n", o->ports[i]); |
2282 |
printf("port %d\n", o->ports[i]); |
| 2246 |
dump_cfg_fmtint(sAddressFamily, o->address_family); |
2283 |
dump_cfg_fmtint(sAddressFamily, o->address_family); |
| 2247 |
|
2284 |
|
| 2248 |
/* |
2285 |
/* ListenAddress must be after Port. */ |
| 2249 |
* ListenAddress must be after Port. add_one_listen_addr pushes |
2286 |
for (i = 0; i < o->num_listen_addrs; i++) { |
| 2250 |
* addresses onto a stack, so to maintain ordering we need to |
2287 |
for (ai = o->listen_addrs[i].addrs; ai; ai = ai->ai_next) { |
| 2251 |
* print these in reverse order. |
2288 |
if ((ret = getnameinfo(ai->ai_addr, ai->ai_addrlen, addr, |
| 2252 |
*/ |
2289 |
sizeof(addr), port, sizeof(port), |
| 2253 |
for (ai = o->listen_addrs; ai; ai = ai->ai_next) { |
2290 |
NI_NUMERICHOST|NI_NUMERICSERV)) != 0) { |
| 2254 |
if ((ret = getnameinfo(ai->ai_addr, ai->ai_addrlen, addr, |
2291 |
error("getnameinfo failed: %.100s", |
| 2255 |
sizeof(addr), port, sizeof(port), |
2292 |
(ret != EAI_SYSTEM) ? gai_strerror(ret) : |
| 2256 |
NI_NUMERICHOST|NI_NUMERICSERV)) != 0) { |
2293 |
strerror(errno)); |
| 2257 |
error("getnameinfo failed: %.100s", |
2294 |
} else { |
| 2258 |
(ret != EAI_SYSTEM) ? gai_strerror(ret) : |
2295 |
if (ai->ai_family == AF_INET6) |
| 2259 |
strerror(errno)); |
2296 |
xasprintf(&laddr, |
| 2260 |
} else { |
2297 |
"%slistenaddress [%s]:%s", laddr, |
| 2261 |
laddr2 = laddr1; |
2298 |
addr, port); |
| 2262 |
if (ai->ai_family == AF_INET6) |
2299 |
else |
| 2263 |
xasprintf(&laddr1, "listenaddress [%s]:%s\n%s", |
2300 |
xasprintf(&laddr, |
| 2264 |
addr, port, laddr2); |
2301 |
"%slistenaddress %s:%s", laddr, |
| 2265 |
else |
2302 |
addr, port); |
| 2266 |
xasprintf(&laddr1, "listenaddress %s:%s\n%s", |
2303 |
if (o->listen_addrs[i].domain) |
| 2267 |
addr, port, laddr2); |
2304 |
xasprintf(&laddr, "%s domain %s\n", |
| 2268 |
free(laddr2); |
2305 |
laddr, o->listen_addrs[i].domain); |
|
|
2306 |
else |
| 2307 |
xasprintf(&laddr, "%s\n", laddr); |
| 2308 |
} |
| 2269 |
} |
2309 |
} |
| 2270 |
} |
2310 |
} |
| 2271 |
printf("%s", laddr1); |
2311 |
printf("%s", laddr); |
| 2272 |
free(laddr1); |
2312 |
free(laddr); |
| 2273 |
|
2313 |
|
| 2274 |
/* integer arguments */ |
2314 |
/* integer arguments */ |
| 2275 |
#ifdef USE_PAM |
2315 |
#ifdef USE_PAM |
|
Lines 2358-2363
dump_config(ServerOptions *o)
Link Here
|
| 2358 |
o->hostkeyalgorithms : KEX_DEFAULT_PK_ALG); |
2398 |
o->hostkeyalgorithms : KEX_DEFAULT_PK_ALG); |
| 2359 |
dump_cfg_string(sPubkeyAcceptedKeyTypes, o->pubkey_key_types ? |
2399 |
dump_cfg_string(sPubkeyAcceptedKeyTypes, o->pubkey_key_types ? |
| 2360 |
o->pubkey_key_types : KEX_DEFAULT_PK_ALG); |
2400 |
o->pubkey_key_types : KEX_DEFAULT_PK_ALG); |
|
|
2401 |
dump_cfg_string(sBindDevice, o->bind_device); |
| 2361 |
|
2402 |
|
| 2362 |
/* string arguments requiring a lookup */ |
2403 |
/* string arguments requiring a lookup */ |
| 2363 |
dump_cfg_string(sLogLevel, log_level_name(o->log_level)); |
2404 |
dump_cfg_string(sLogLevel, log_level_name(o->log_level)); |