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