Annotation of src/usr.bin/ssh/servconf.c, Revision 1.64
1.1 deraadt 1: /*
1.26 deraadt 2: * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
3: * All rights reserved
1.34 markus 4: *
1.51 deraadt 5: * As far as I am concerned, the code I have written for this software
6: * can be used freely for any purpose. Any derived versions of this
7: * software must be clearly marked as such, and if the derived work is
8: * incompatible with the protocol description in the RFC file, it must be
9: * called by a name other than "ssh" or "Secure Shell".
1.26 deraadt 10: */
1.1 deraadt 11:
12: #include "includes.h"
1.64 ! markus 13: RCSID("$OpenBSD: servconf.c,v 1.63 2001/01/22 23:06:39 markus Exp $");
1.62 markus 14:
15: #ifdef KRB4
16: #include <krb.h>
17: #endif
18: #ifdef AFS
19: #include <kafs.h>
20: #endif
1.1 deraadt 21:
22: #include "ssh.h"
1.62 markus 23: #include "log.h"
1.1 deraadt 24: #include "servconf.h"
25: #include "xmalloc.h"
1.33 markus 26: #include "compat.h"
1.60 markus 27: #include "pathnames.h"
1.62 markus 28: #include "tildexpand.h"
29: #include "misc.h"
30: #include "cipher.h"
1.1 deraadt 31:
1.29 markus 32: /* add listen address */
33: void add_listen_addr(ServerOptions *options, char *addr);
34:
1.62 markus 35: /* AF_UNSPEC or AF_INET or AF_INET6 */
36: extern int IPv4or6;
37:
1.1 deraadt 38: /* Initializes the server options to their default values. */
39:
1.34 markus 40: void
1.25 markus 41: initialize_server_options(ServerOptions *options)
1.1 deraadt 42: {
1.25 markus 43: memset(options, 0, sizeof(*options));
1.29 markus 44: options->num_ports = 0;
45: options->ports_from_cmdline = 0;
46: options->listen_addrs = NULL;
1.54 markus 47: options->num_host_key_files = 0;
1.36 markus 48: options->pid_file = NULL;
1.25 markus 49: options->server_key_bits = -1;
50: options->login_grace_time = -1;
51: options->key_regeneration_time = -1;
52: options->permit_root_login = -1;
53: options->ignore_rhosts = -1;
54: options->ignore_user_known_hosts = -1;
55: options->print_motd = -1;
56: options->check_mail = -1;
57: options->x11_forwarding = -1;
58: options->x11_display_offset = -1;
1.42 markus 59: options->xauth_location = NULL;
1.25 markus 60: options->strict_modes = -1;
61: options->keepalives = -1;
62: options->log_facility = (SyslogFacility) - 1;
63: options->log_level = (LogLevel) - 1;
64: options->rhosts_authentication = -1;
65: options->rhosts_rsa_authentication = -1;
66: options->rsa_authentication = -1;
1.54 markus 67: options->pubkey_authentication = -1;
1.1 deraadt 68: #ifdef KRB4
1.25 markus 69: options->kerberos_authentication = -1;
70: options->kerberos_or_local_passwd = -1;
71: options->kerberos_ticket_cleanup = -1;
1.1 deraadt 72: #endif
1.4 dugsong 73: #ifdef AFS
1.25 markus 74: options->kerberos_tgt_passing = -1;
75: options->afs_token_passing = -1;
1.1 deraadt 76: #endif
1.25 markus 77: options->password_authentication = -1;
1.52 markus 78: options->kbd_interactive_authentication = -1;
1.63 markus 79: options->challenge_reponse_authentication = -1;
1.25 markus 80: options->permit_empty_passwd = -1;
81: options->use_login = -1;
1.53 markus 82: options->allow_tcp_forwarding = -1;
1.25 markus 83: options->num_allow_users = 0;
84: options->num_deny_users = 0;
85: options->num_allow_groups = 0;
86: options->num_deny_groups = 0;
1.33 markus 87: options->ciphers = NULL;
88: options->protocol = SSH_PROTO_UNKNOWN;
1.38 markus 89: options->gateway_ports = -1;
1.43 jakob 90: options->num_subsystems = 0;
1.50 markus 91: options->max_startups_begin = -1;
92: options->max_startups_rate = -1;
1.46 markus 93: options->max_startups = -1;
1.57 markus 94: options->banner = NULL;
1.64 ! markus 95: options->reverse_mapping_check = -1;
1.1 deraadt 96: }
97:
1.34 markus 98: void
1.25 markus 99: fill_default_server_options(ServerOptions *options)
1.1 deraadt 100: {
1.54 markus 101: if (options->protocol == SSH_PROTO_UNKNOWN)
102: options->protocol = SSH_PROTO_1|SSH_PROTO_2;
103: if (options->num_host_key_files == 0) {
104: /* fill default hostkeys for protocols */
105: if (options->protocol & SSH_PROTO_1)
1.60 markus 106: options->host_key_files[options->num_host_key_files++] = _PATH_HOST_KEY_FILE;
1.54 markus 107: if (options->protocol & SSH_PROTO_2)
1.60 markus 108: options->host_key_files[options->num_host_key_files++] = _PATH_HOST_DSA_KEY_FILE;
1.54 markus 109: }
1.29 markus 110: if (options->num_ports == 0)
111: options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
112: if (options->listen_addrs == NULL)
113: add_listen_addr(options, NULL);
1.36 markus 114: if (options->pid_file == NULL)
1.60 markus 115: options->pid_file = _PATH_SSH_DAEMON_PID_FILE;
1.25 markus 116: if (options->server_key_bits == -1)
117: options->server_key_bits = 768;
118: if (options->login_grace_time == -1)
119: options->login_grace_time = 600;
120: if (options->key_regeneration_time == -1)
121: options->key_regeneration_time = 3600;
122: if (options->permit_root_login == -1)
123: options->permit_root_login = 1; /* yes */
124: if (options->ignore_rhosts == -1)
1.30 markus 125: options->ignore_rhosts = 1;
1.25 markus 126: if (options->ignore_user_known_hosts == -1)
127: options->ignore_user_known_hosts = 0;
128: if (options->check_mail == -1)
129: options->check_mail = 0;
130: if (options->print_motd == -1)
131: options->print_motd = 1;
132: if (options->x11_forwarding == -1)
1.30 markus 133: options->x11_forwarding = 0;
1.25 markus 134: if (options->x11_display_offset == -1)
1.30 markus 135: options->x11_display_offset = 10;
1.42 markus 136: #ifdef XAUTH_PATH
137: if (options->xauth_location == NULL)
138: options->xauth_location = XAUTH_PATH;
139: #endif /* XAUTH_PATH */
1.25 markus 140: if (options->strict_modes == -1)
141: options->strict_modes = 1;
142: if (options->keepalives == -1)
143: options->keepalives = 1;
144: if (options->log_facility == (SyslogFacility) (-1))
145: options->log_facility = SYSLOG_FACILITY_AUTH;
146: if (options->log_level == (LogLevel) (-1))
1.58 markus 147: options->log_level = SYSLOG_LEVEL_INFO;
1.25 markus 148: if (options->rhosts_authentication == -1)
149: options->rhosts_authentication = 0;
150: if (options->rhosts_rsa_authentication == -1)
1.30 markus 151: options->rhosts_rsa_authentication = 0;
1.25 markus 152: if (options->rsa_authentication == -1)
153: options->rsa_authentication = 1;
1.54 markus 154: if (options->pubkey_authentication == -1)
155: options->pubkey_authentication = 1;
1.1 deraadt 156: #ifdef KRB4
1.25 markus 157: if (options->kerberos_authentication == -1)
158: options->kerberos_authentication = (access(KEYFILE, R_OK) == 0);
159: if (options->kerberos_or_local_passwd == -1)
160: options->kerberos_or_local_passwd = 1;
161: if (options->kerberos_ticket_cleanup == -1)
162: options->kerberos_ticket_cleanup = 1;
1.4 dugsong 163: #endif /* KRB4 */
164: #ifdef AFS
1.25 markus 165: if (options->kerberos_tgt_passing == -1)
166: options->kerberos_tgt_passing = 0;
167: if (options->afs_token_passing == -1)
168: options->afs_token_passing = k_hasafs();
1.4 dugsong 169: #endif /* AFS */
1.25 markus 170: if (options->password_authentication == -1)
171: options->password_authentication = 1;
1.52 markus 172: if (options->kbd_interactive_authentication == -1)
173: options->kbd_interactive_authentication = 0;
1.63 markus 174: if (options->challenge_reponse_authentication == -1)
175: options->challenge_reponse_authentication = 1;
1.25 markus 176: if (options->permit_empty_passwd == -1)
1.30 markus 177: options->permit_empty_passwd = 0;
1.25 markus 178: if (options->use_login == -1)
179: options->use_login = 0;
1.53 markus 180: if (options->allow_tcp_forwarding == -1)
181: options->allow_tcp_forwarding = 1;
1.38 markus 182: if (options->gateway_ports == -1)
183: options->gateway_ports = 0;
1.46 markus 184: if (options->max_startups == -1)
185: options->max_startups = 10;
1.50 markus 186: if (options->max_startups_rate == -1)
187: options->max_startups_rate = 100; /* 100% */
188: if (options->max_startups_begin == -1)
189: options->max_startups_begin = options->max_startups;
1.64 ! markus 190: if (options->reverse_mapping_check == -1)
! 191: options->reverse_mapping_check = 0;
1.1 deraadt 192: }
193:
194: /* Keyword tokens. */
1.25 markus 195: typedef enum {
196: sBadOption, /* == unknown option */
197: sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime, sKeyRegenerationTime,
198: sPermitRootLogin, sLogFacility, sLogLevel,
199: sRhostsAuthentication, sRhostsRSAAuthentication, sRSAAuthentication,
1.1 deraadt 200: #ifdef KRB4
1.25 markus 201: sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup,
1.1 deraadt 202: #endif
203: #ifdef AFS
1.25 markus 204: sKerberosTgtPassing, sAFSTokenPassing,
1.1 deraadt 205: #endif
1.63 markus 206: sChallengeResponseAuthentication,
1.52 markus 207: sPasswordAuthentication, sKbdInteractiveAuthentication, sListenAddress,
1.25 markus 208: sPrintMotd, sIgnoreRhosts, sX11Forwarding, sX11DisplayOffset,
209: sStrictModes, sEmptyPasswd, sRandomSeedFile, sKeepAlives, sCheckMail,
1.53 markus 210: sUseLogin, sAllowTcpForwarding,
211: sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
1.54 markus 212: sIgnoreUserKnownHosts, sCiphers, sProtocol, sPidFile,
213: sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, sMaxStartups,
1.64 ! markus 214: sBanner, sReverseMappingCheck
1.1 deraadt 215: } ServerOpCodes;
216:
217: /* Textual representation of the tokens. */
1.25 markus 218: static struct {
219: const char *name;
220: ServerOpCodes opcode;
221: } keywords[] = {
222: { "port", sPort },
223: { "hostkey", sHostKeyFile },
1.54 markus 224: { "hostdsakey", sHostKeyFile }, /* alias */
1.36 markus 225: { "pidfile", sPidFile },
1.25 markus 226: { "serverkeybits", sServerKeyBits },
227: { "logingracetime", sLoginGraceTime },
228: { "keyregenerationinterval", sKeyRegenerationTime },
229: { "permitrootlogin", sPermitRootLogin },
230: { "syslogfacility", sLogFacility },
231: { "loglevel", sLogLevel },
232: { "rhostsauthentication", sRhostsAuthentication },
233: { "rhostsrsaauthentication", sRhostsRSAAuthentication },
234: { "rsaauthentication", sRSAAuthentication },
1.54 markus 235: { "pubkeyauthentication", sPubkeyAuthentication },
236: { "dsaauthentication", sPubkeyAuthentication }, /* alias */
1.1 deraadt 237: #ifdef KRB4
1.25 markus 238: { "kerberosauthentication", sKerberosAuthentication },
239: { "kerberosorlocalpasswd", sKerberosOrLocalPasswd },
240: { "kerberosticketcleanup", sKerberosTicketCleanup },
1.1 deraadt 241: #endif
1.4 dugsong 242: #ifdef AFS
1.25 markus 243: { "kerberostgtpassing", sKerberosTgtPassing },
244: { "afstokenpassing", sAFSTokenPassing },
1.1 deraadt 245: #endif
1.25 markus 246: { "passwordauthentication", sPasswordAuthentication },
1.52 markus 247: { "kbdinteractiveauthentication", sKbdInteractiveAuthentication },
1.63 markus 248: { "challengeresponseauthentication", sChallengeResponseAuthentication },
249: { "skeyauthentication", sChallengeResponseAuthentication }, /* alias */
1.25 markus 250: { "checkmail", sCheckMail },
251: { "listenaddress", sListenAddress },
252: { "printmotd", sPrintMotd },
253: { "ignorerhosts", sIgnoreRhosts },
254: { "ignoreuserknownhosts", sIgnoreUserKnownHosts },
255: { "x11forwarding", sX11Forwarding },
256: { "x11displayoffset", sX11DisplayOffset },
1.42 markus 257: { "xauthlocation", sXAuthLocation },
1.25 markus 258: { "strictmodes", sStrictModes },
259: { "permitemptypasswords", sEmptyPasswd },
260: { "uselogin", sUseLogin },
261: { "randomseed", sRandomSeedFile },
262: { "keepalive", sKeepAlives },
1.53 markus 263: { "allowtcpforwarding", sAllowTcpForwarding },
1.25 markus 264: { "allowusers", sAllowUsers },
265: { "denyusers", sDenyUsers },
266: { "allowgroups", sAllowGroups },
267: { "denygroups", sDenyGroups },
1.33 markus 268: { "ciphers", sCiphers },
269: { "protocol", sProtocol },
1.38 markus 270: { "gatewayports", sGatewayPorts },
1.43 jakob 271: { "subsystem", sSubsystem },
1.46 markus 272: { "maxstartups", sMaxStartups },
1.57 markus 273: { "banner", sBanner },
1.64 ! markus 274: { "reversemappingcheck", sReverseMappingCheck },
1.25 markus 275: { NULL, 0 }
1.1 deraadt 276: };
277:
1.27 markus 278: /*
279: * Returns the number of the token pointed to by cp of length len. Never
280: * returns if the token is not known.
281: */
1.1 deraadt 282:
1.34 markus 283: static ServerOpCodes
1.25 markus 284: parse_token(const char *cp, const char *filename,
285: int linenum)
1.1 deraadt 286: {
1.55 markus 287: u_int i;
1.1 deraadt 288:
1.25 markus 289: for (i = 0; keywords[i].name; i++)
1.28 markus 290: if (strcasecmp(cp, keywords[i].name) == 0)
1.25 markus 291: return keywords[i].opcode;
292:
293: fprintf(stderr, "%s: line %d: Bad configuration option: %s\n",
294: filename, linenum, cp);
295: return sBadOption;
1.1 deraadt 296: }
297:
1.29 markus 298: /*
299: * add listen address
300: */
1.34 markus 301: void
1.29 markus 302: add_listen_addr(ServerOptions *options, char *addr)
303: {
304: struct addrinfo hints, *ai, *aitop;
305: char strport[NI_MAXSERV];
306: int gaierr;
307: int i;
308:
309: if (options->num_ports == 0)
310: options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
311: for (i = 0; i < options->num_ports; i++) {
312: memset(&hints, 0, sizeof(hints));
313: hints.ai_family = IPv4or6;
314: hints.ai_socktype = SOCK_STREAM;
315: hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0;
316: snprintf(strport, sizeof strport, "%d", options->ports[i]);
317: if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
318: fatal("bad addr or host: %s (%s)\n",
319: addr ? addr : "<NULL>",
320: gai_strerror(gaierr));
321: for (ai = aitop; ai->ai_next; ai = ai->ai_next)
322: ;
323: ai->ai_next = options->listen_addrs;
324: options->listen_addrs = aitop;
325: }
326: }
327:
1.1 deraadt 328: /* Reads the server configuration file. */
329:
1.34 markus 330: void
1.25 markus 331: read_server_config(ServerOptions *options, const char *filename)
1.1 deraadt 332: {
1.25 markus 333: FILE *f;
334: char line[1024];
1.47 ho 335: char *cp, **charptr, *arg;
1.25 markus 336: int linenum, *intptr, value;
337: int bad_options = 0;
338: ServerOpCodes opcode;
1.43 jakob 339: int i;
1.25 markus 340:
341: f = fopen(filename, "r");
342: if (!f) {
343: perror(filename);
1.1 deraadt 344: exit(1);
1.25 markus 345: }
346: linenum = 0;
347: while (fgets(line, sizeof(line), f)) {
348: linenum++;
1.48 provos 349: cp = line;
350: arg = strdelim(&cp);
351: /* Ignore leading whitespace */
352: if (*arg == '\0')
1.49 markus 353: arg = strdelim(&cp);
1.61 djm 354: if (!arg || !*arg || *arg == '#')
1.25 markus 355: continue;
1.54 markus 356: intptr = NULL;
357: charptr = NULL;
1.47 ho 358: opcode = parse_token(arg, filename, linenum);
1.25 markus 359: switch (opcode) {
360: case sBadOption:
361: bad_options++;
362: continue;
363: case sPort:
1.29 markus 364: /* ignore ports from configfile if cmdline specifies ports */
365: if (options->ports_from_cmdline)
366: continue;
367: if (options->listen_addrs != NULL)
368: fatal("%s line %d: ports must be specified before "
369: "ListenAdress.\n", filename, linenum);
370: if (options->num_ports >= MAX_PORTS)
371: fatal("%s line %d: too many ports.\n",
1.34 markus 372: filename, linenum);
1.48 provos 373: arg = strdelim(&cp);
1.47 ho 374: if (!arg || *arg == '\0')
1.29 markus 375: fatal("%s line %d: missing port number.\n",
376: filename, linenum);
1.47 ho 377: options->ports[options->num_ports++] = atoi(arg);
1.29 markus 378: break;
379:
380: case sServerKeyBits:
381: intptr = &options->server_key_bits;
1.25 markus 382: parse_int:
1.48 provos 383: arg = strdelim(&cp);
1.47 ho 384: if (!arg || *arg == '\0') {
1.25 markus 385: fprintf(stderr, "%s line %d: missing integer value.\n",
386: filename, linenum);
387: exit(1);
388: }
1.47 ho 389: value = atoi(arg);
1.25 markus 390: if (*intptr == -1)
391: *intptr = value;
392: break;
393:
394: case sLoginGraceTime:
395: intptr = &options->login_grace_time;
396: goto parse_int;
397:
398: case sKeyRegenerationTime:
399: intptr = &options->key_regeneration_time;
400: goto parse_int;
401:
402: case sListenAddress:
1.48 provos 403: arg = strdelim(&cp);
1.47 ho 404: if (!arg || *arg == '\0')
1.29 markus 405: fatal("%s line %d: missing inet addr.\n",
406: filename, linenum);
1.47 ho 407: add_listen_addr(options, arg);
1.25 markus 408: break;
409:
410: case sHostKeyFile:
1.54 markus 411: intptr = &options->num_host_key_files;
412: if (*intptr >= MAX_HOSTKEYS) {
413: fprintf(stderr, "%s line %d: to many host keys specified (max %d).\n",
414: filename, linenum, MAX_HOSTKEYS);
415: exit(1);
416: }
417: charptr = &options->host_key_files[*intptr];
1.42 markus 418: parse_filename:
1.48 provos 419: arg = strdelim(&cp);
1.47 ho 420: if (!arg || *arg == '\0') {
1.25 markus 421: fprintf(stderr, "%s line %d: missing file name.\n",
1.36 markus 422: filename, linenum);
423: exit(1);
424: }
1.54 markus 425: if (*charptr == NULL) {
1.47 ho 426: *charptr = tilde_expand_filename(arg, getuid());
1.54 markus 427: /* increase optional counter */
428: if (intptr != NULL)
429: *intptr = *intptr + 1;
430: }
1.36 markus 431: break;
432:
433: case sPidFile:
434: charptr = &options->pid_file;
1.42 markus 435: goto parse_filename;
1.25 markus 436:
437: case sRandomSeedFile:
438: fprintf(stderr, "%s line %d: \"randomseed\" option is obsolete.\n",
439: filename, linenum);
1.48 provos 440: arg = strdelim(&cp);
1.25 markus 441: break;
442:
443: case sPermitRootLogin:
444: intptr = &options->permit_root_login;
1.48 provos 445: arg = strdelim(&cp);
1.47 ho 446: if (!arg || *arg == '\0') {
1.25 markus 447: fprintf(stderr, "%s line %d: missing yes/without-password/no argument.\n",
448: filename, linenum);
449: exit(1);
450: }
1.47 ho 451: if (strcmp(arg, "without-password") == 0)
1.25 markus 452: value = 2;
1.47 ho 453: else if (strcmp(arg, "yes") == 0)
1.25 markus 454: value = 1;
1.47 ho 455: else if (strcmp(arg, "no") == 0)
1.25 markus 456: value = 0;
457: else {
458: fprintf(stderr, "%s line %d: Bad yes/without-password/no argument: %s\n",
1.47 ho 459: filename, linenum, arg);
1.25 markus 460: exit(1);
461: }
462: if (*intptr == -1)
463: *intptr = value;
464: break;
465:
466: case sIgnoreRhosts:
467: intptr = &options->ignore_rhosts;
468: parse_flag:
1.48 provos 469: arg = strdelim(&cp);
1.47 ho 470: if (!arg || *arg == '\0') {
1.25 markus 471: fprintf(stderr, "%s line %d: missing yes/no argument.\n",
472: filename, linenum);
473: exit(1);
474: }
1.47 ho 475: if (strcmp(arg, "yes") == 0)
1.25 markus 476: value = 1;
1.47 ho 477: else if (strcmp(arg, "no") == 0)
1.25 markus 478: value = 0;
479: else {
480: fprintf(stderr, "%s line %d: Bad yes/no argument: %s\n",
1.47 ho 481: filename, linenum, arg);
1.25 markus 482: exit(1);
483: }
484: if (*intptr == -1)
485: *intptr = value;
486: break;
487:
488: case sIgnoreUserKnownHosts:
489: intptr = &options->ignore_user_known_hosts;
1.31 markus 490: goto parse_flag;
1.25 markus 491:
492: case sRhostsAuthentication:
493: intptr = &options->rhosts_authentication;
494: goto parse_flag;
495:
496: case sRhostsRSAAuthentication:
497: intptr = &options->rhosts_rsa_authentication;
498: goto parse_flag;
499:
500: case sRSAAuthentication:
501: intptr = &options->rsa_authentication;
1.39 markus 502: goto parse_flag;
503:
1.54 markus 504: case sPubkeyAuthentication:
505: intptr = &options->pubkey_authentication;
1.25 markus 506: goto parse_flag;
507:
1.1 deraadt 508: #ifdef KRB4
1.25 markus 509: case sKerberosAuthentication:
510: intptr = &options->kerberos_authentication;
511: goto parse_flag;
512:
513: case sKerberosOrLocalPasswd:
514: intptr = &options->kerberos_or_local_passwd;
515: goto parse_flag;
516:
517: case sKerberosTicketCleanup:
518: intptr = &options->kerberos_ticket_cleanup;
519: goto parse_flag;
1.1 deraadt 520: #endif
1.25 markus 521:
1.4 dugsong 522: #ifdef AFS
1.25 markus 523: case sKerberosTgtPassing:
524: intptr = &options->kerberos_tgt_passing;
525: goto parse_flag;
526:
527: case sAFSTokenPassing:
528: intptr = &options->afs_token_passing;
529: goto parse_flag;
530: #endif
531:
532: case sPasswordAuthentication:
533: intptr = &options->password_authentication;
1.52 markus 534: goto parse_flag;
535:
536: case sKbdInteractiveAuthentication:
537: intptr = &options->kbd_interactive_authentication;
1.25 markus 538: goto parse_flag;
539:
540: case sCheckMail:
541: intptr = &options->check_mail;
542: goto parse_flag;
1.10 markus 543:
1.63 markus 544: case sChallengeResponseAuthentication:
545: intptr = &options->challenge_reponse_authentication;
1.25 markus 546: goto parse_flag;
547:
548: case sPrintMotd:
549: intptr = &options->print_motd;
550: goto parse_flag;
551:
552: case sX11Forwarding:
553: intptr = &options->x11_forwarding;
554: goto parse_flag;
555:
556: case sX11DisplayOffset:
557: intptr = &options->x11_display_offset;
558: goto parse_int;
559:
1.42 markus 560: case sXAuthLocation:
561: charptr = &options->xauth_location;
562: goto parse_filename;
563:
1.25 markus 564: case sStrictModes:
565: intptr = &options->strict_modes;
566: goto parse_flag;
567:
568: case sKeepAlives:
569: intptr = &options->keepalives;
570: goto parse_flag;
571:
572: case sEmptyPasswd:
573: intptr = &options->permit_empty_passwd;
574: goto parse_flag;
575:
576: case sUseLogin:
577: intptr = &options->use_login;
1.38 markus 578: goto parse_flag;
579:
580: case sGatewayPorts:
581: intptr = &options->gateway_ports;
1.64 ! markus 582: goto parse_flag;
! 583:
! 584: case sReverseMappingCheck:
! 585: intptr = &options->reverse_mapping_check;
1.25 markus 586: goto parse_flag;
587:
588: case sLogFacility:
589: intptr = (int *) &options->log_facility;
1.48 provos 590: arg = strdelim(&cp);
1.47 ho 591: value = log_facility_number(arg);
1.25 markus 592: if (value == (SyslogFacility) - 1)
593: fatal("%.200s line %d: unsupported log facility '%s'\n",
1.47 ho 594: filename, linenum, arg ? arg : "<NONE>");
1.25 markus 595: if (*intptr == -1)
596: *intptr = (SyslogFacility) value;
597: break;
598:
599: case sLogLevel:
600: intptr = (int *) &options->log_level;
1.48 provos 601: arg = strdelim(&cp);
1.47 ho 602: value = log_level_number(arg);
1.25 markus 603: if (value == (LogLevel) - 1)
604: fatal("%.200s line %d: unsupported log level '%s'\n",
1.47 ho 605: filename, linenum, arg ? arg : "<NONE>");
1.25 markus 606: if (*intptr == -1)
607: *intptr = (LogLevel) value;
608: break;
1.53 markus 609:
610: case sAllowTcpForwarding:
611: intptr = &options->allow_tcp_forwarding;
612: goto parse_flag;
1.25 markus 613:
614: case sAllowUsers:
1.48 provos 615: while ((arg = strdelim(&cp)) && *arg != '\0') {
1.33 markus 616: if (options->num_allow_users >= MAX_ALLOW_USERS)
617: fatal("%s line %d: too many allow users.\n",
618: filename, linenum);
1.47 ho 619: options->allow_users[options->num_allow_users++] = xstrdup(arg);
1.25 markus 620: }
621: break;
622:
623: case sDenyUsers:
1.48 provos 624: while ((arg = strdelim(&cp)) && *arg != '\0') {
1.33 markus 625: if (options->num_deny_users >= MAX_DENY_USERS)
626: fatal( "%s line %d: too many deny users.\n",
627: filename, linenum);
1.47 ho 628: options->deny_users[options->num_deny_users++] = xstrdup(arg);
1.25 markus 629: }
630: break;
631:
632: case sAllowGroups:
1.48 provos 633: while ((arg = strdelim(&cp)) && *arg != '\0') {
1.33 markus 634: if (options->num_allow_groups >= MAX_ALLOW_GROUPS)
635: fatal("%s line %d: too many allow groups.\n",
636: filename, linenum);
1.47 ho 637: options->allow_groups[options->num_allow_groups++] = xstrdup(arg);
1.25 markus 638: }
639: break;
640:
641: case sDenyGroups:
1.48 provos 642: while ((arg = strdelim(&cp)) && *arg != '\0') {
1.33 markus 643: if (options->num_deny_groups >= MAX_DENY_GROUPS)
644: fatal("%s line %d: too many deny groups.\n",
645: filename, linenum);
1.47 ho 646: options->deny_groups[options->num_deny_groups++] = xstrdup(arg);
1.25 markus 647: }
1.33 markus 648: break;
649:
650: case sCiphers:
1.48 provos 651: arg = strdelim(&cp);
1.47 ho 652: if (!arg || *arg == '\0')
1.41 markus 653: fatal("%s line %d: Missing argument.", filename, linenum);
1.47 ho 654: if (!ciphers_valid(arg))
1.40 markus 655: fatal("%s line %d: Bad SSH2 cipher spec '%s'.",
1.47 ho 656: filename, linenum, arg ? arg : "<NONE>");
1.33 markus 657: if (options->ciphers == NULL)
1.47 ho 658: options->ciphers = xstrdup(arg);
1.33 markus 659: break;
660:
661: case sProtocol:
662: intptr = &options->protocol;
1.48 provos 663: arg = strdelim(&cp);
1.47 ho 664: if (!arg || *arg == '\0')
1.41 markus 665: fatal("%s line %d: Missing argument.", filename, linenum);
1.47 ho 666: value = proto_spec(arg);
1.33 markus 667: if (value == SSH_PROTO_UNKNOWN)
668: fatal("%s line %d: Bad protocol spec '%s'.",
1.47 ho 669: filename, linenum, arg ? arg : "<NONE>");
1.33 markus 670: if (*intptr == SSH_PROTO_UNKNOWN)
671: *intptr = value;
1.43 jakob 672: break;
673:
674: case sSubsystem:
675: if(options->num_subsystems >= MAX_SUBSYSTEMS) {
676: fatal("%s line %d: too many subsystems defined.",
677: filename, linenum);
678: }
1.48 provos 679: arg = strdelim(&cp);
1.47 ho 680: if (!arg || *arg == '\0')
1.43 jakob 681: fatal("%s line %d: Missing subsystem name.",
682: filename, linenum);
683: for (i = 0; i < options->num_subsystems; i++)
1.47 ho 684: if(strcmp(arg, options->subsystem_name[i]) == 0)
1.43 jakob 685: fatal("%s line %d: Subsystem '%s' already defined.",
1.47 ho 686: filename, linenum, arg);
687: options->subsystem_name[options->num_subsystems] = xstrdup(arg);
1.48 provos 688: arg = strdelim(&cp);
1.47 ho 689: if (!arg || *arg == '\0')
1.43 jakob 690: fatal("%s line %d: Missing subsystem command.",
691: filename, linenum);
1.47 ho 692: options->subsystem_command[options->num_subsystems] = xstrdup(arg);
1.43 jakob 693: options->num_subsystems++;
1.25 markus 694: break;
1.46 markus 695:
696: case sMaxStartups:
1.50 markus 697: arg = strdelim(&cp);
698: if (!arg || *arg == '\0')
699: fatal("%s line %d: Missing MaxStartups spec.",
700: filename, linenum);
701: if (sscanf(arg, "%d:%d:%d",
702: &options->max_startups_begin,
703: &options->max_startups_rate,
704: &options->max_startups) == 3) {
705: if (options->max_startups_begin >
706: options->max_startups ||
707: options->max_startups_rate > 100 ||
708: options->max_startups_rate < 1)
709: fatal("%s line %d: Illegal MaxStartups spec.",
710: filename, linenum);
711: break;
712: }
1.46 markus 713: intptr = &options->max_startups;
714: goto parse_int;
1.25 markus 715:
1.57 markus 716: case sBanner:
717: charptr = &options->banner;
718: goto parse_filename;
719:
1.25 markus 720: default:
721: fprintf(stderr, "%s line %d: Missing handler for opcode %s (%d)\n",
1.47 ho 722: filename, linenum, arg, opcode);
1.25 markus 723: exit(1);
1.13 markus 724: }
1.48 provos 725: if ((arg = strdelim(&cp)) != NULL && *arg != '\0') {
1.47 ho 726: fprintf(stderr,
727: "%s line %d: garbage at end of line; \"%.200s\".\n",
728: filename, linenum, arg);
1.25 markus 729: exit(1);
1.13 markus 730: }
1.1 deraadt 731: }
1.25 markus 732: fclose(f);
733: if (bad_options > 0) {
734: fprintf(stderr, "%s: terminating, %d bad configuration options\n",
735: filename, bad_options);
736: exit(1);
1.1 deraadt 737: }
738: }