servconf.c (57430) | servconf.c (57432) |
---|---|
1/* 2 * 3 * servconf.c 4 * 5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 6 * 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 8 * All rights reserved 9 * 10 * Created: Mon Aug 21 15:48:58 1995 ylo 11 * | 1/* 2 * 3 * servconf.c 4 * 5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 6 * 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 8 * All rights reserved 9 * 10 * Created: Mon Aug 21 15:48:58 1995 ylo 11 * |
12 * $FreeBSD: head/crypto/openssh/servconf.c 57432 2000-02-24 15:29:42Z markm $ |
|
12 */ 13 14#include "includes.h" 15RCSID("$Id: servconf.c,v 1.29 2000/01/04 00:07:59 markus Exp $"); 16 17#include "ssh.h" 18#include "servconf.h" 19#include "xmalloc.h" --- 42 unchanged lines hidden (view full) --- 62 options->skey_authentication = -1; 63#endif 64 options->permit_empty_passwd = -1; 65 options->use_login = -1; 66 options->num_allow_users = 0; 67 options->num_deny_users = 0; 68 options->num_allow_groups = 0; 69 options->num_deny_groups = 0; | 13 */ 14 15#include "includes.h" 16RCSID("$Id: servconf.c,v 1.29 2000/01/04 00:07:59 markus Exp $"); 17 18#include "ssh.h" 19#include "servconf.h" 20#include "xmalloc.h" --- 42 unchanged lines hidden (view full) --- 63 options->skey_authentication = -1; 64#endif 65 options->permit_empty_passwd = -1; 66 options->use_login = -1; 67 options->num_allow_users = 0; 68 options->num_deny_users = 0; 69 options->num_allow_groups = 0; 70 options->num_deny_groups = 0; |
71 options->connections_per_period = 0; 72 options->connections_period = 0; |
|
70} 71 72void 73fill_default_server_options(ServerOptions *options) 74{ 75 if (options->num_ports == 0) 76 options->ports[options->num_ports++] = SSH_DEFAULT_PORT; 77 if (options->listen_addrs == NULL) --- 76 unchanged lines hidden (view full) --- 154#endif 155#ifdef SKEY 156 sSkeyAuthentication, 157#endif 158 sPasswordAuthentication, sListenAddress, 159 sPrintMotd, sIgnoreRhosts, sX11Forwarding, sX11DisplayOffset, 160 sStrictModes, sEmptyPasswd, sRandomSeedFile, sKeepAlives, sCheckMail, 161 sUseLogin, sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups, | 73} 74 75void 76fill_default_server_options(ServerOptions *options) 77{ 78 if (options->num_ports == 0) 79 options->ports[options->num_ports++] = SSH_DEFAULT_PORT; 80 if (options->listen_addrs == NULL) --- 76 unchanged lines hidden (view full) --- 157#endif 158#ifdef SKEY 159 sSkeyAuthentication, 160#endif 161 sPasswordAuthentication, sListenAddress, 162 sPrintMotd, sIgnoreRhosts, sX11Forwarding, sX11DisplayOffset, 163 sStrictModes, sEmptyPasswd, sRandomSeedFile, sKeepAlives, sCheckMail, 164 sUseLogin, sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups, |
162 sIgnoreUserKnownHosts | 165 sIgnoreUserKnownHosts, sConnectionsPerPeriod |
163} ServerOpCodes; 164 165/* Textual representation of the tokens. */ 166static struct { 167 const char *name; 168 ServerOpCodes opcode; 169} keywords[] = { 170 { "port", sPort }, --- 31 unchanged lines hidden (view full) --- 202 { "permitemptypasswords", sEmptyPasswd }, 203 { "uselogin", sUseLogin }, 204 { "randomseed", sRandomSeedFile }, 205 { "keepalive", sKeepAlives }, 206 { "allowusers", sAllowUsers }, 207 { "denyusers", sDenyUsers }, 208 { "allowgroups", sAllowGroups }, 209 { "denygroups", sDenyGroups }, | 166} ServerOpCodes; 167 168/* Textual representation of the tokens. */ 169static struct { 170 const char *name; 171 ServerOpCodes opcode; 172} keywords[] = { 173 { "port", sPort }, --- 31 unchanged lines hidden (view full) --- 205 { "permitemptypasswords", sEmptyPasswd }, 206 { "uselogin", sUseLogin }, 207 { "randomseed", sRandomSeedFile }, 208 { "keepalive", sKeepAlives }, 209 { "allowusers", sAllowUsers }, 210 { "denyusers", sDenyUsers }, 211 { "allowgroups", sAllowGroups }, 212 { "denygroups", sDenyGroups }, |
213 { "connectionsperperiod", sConnectionsPerPeriod }, |
|
210 { NULL, 0 } 211}; 212 213/* 214 * Returns the number of the token pointed to by cp of length len. Never 215 * returns if the token is not known. 216 */ 217 --- 93 unchanged lines hidden (view full) --- 311 intptr = &options->server_key_bits; 312parse_int: 313 cp = strtok(NULL, WHITESPACE); 314 if (!cp) { 315 fprintf(stderr, "%s line %d: missing integer value.\n", 316 filename, linenum); 317 exit(1); 318 } | 214 { NULL, 0 } 215}; 216 217/* 218 * Returns the number of the token pointed to by cp of length len. Never 219 * returns if the token is not known. 220 */ 221 --- 93 unchanged lines hidden (view full) --- 315 intptr = &options->server_key_bits; 316parse_int: 317 cp = strtok(NULL, WHITESPACE); 318 if (!cp) { 319 fprintf(stderr, "%s line %d: missing integer value.\n", 320 filename, linenum); 321 exit(1); 322 } |
319 value = atoi(cp); | 323 if (sscanf(cp, " %d ", &value) != 1) { 324 fprintf(stderr, "%s line %d: invalid integer value.\n", 325 filename, linenum); 326 exit(1); 327 } |
320 if (*intptr == -1) 321 *intptr = value; 322 break; 323 324 case sLoginGraceTime: 325 intptr = &options->login_grace_time; 326 goto parse_int; 327 --- 173 unchanged lines hidden (view full) --- 501 fatal("%.200s line %d: unsupported log level '%s'\n", 502 filename, linenum, cp ? cp : "<NONE>"); 503 if (*intptr == -1) 504 *intptr = (LogLevel) value; 505 break; 506 507 case sAllowUsers: 508 while ((cp = strtok(NULL, WHITESPACE))) { | 328 if (*intptr == -1) 329 *intptr = value; 330 break; 331 332 case sLoginGraceTime: 333 intptr = &options->login_grace_time; 334 goto parse_int; 335 --- 173 unchanged lines hidden (view full) --- 509 fatal("%.200s line %d: unsupported log level '%s'\n", 510 filename, linenum, cp ? cp : "<NONE>"); 511 if (*intptr == -1) 512 *intptr = (LogLevel) value; 513 break; 514 515 case sAllowUsers: 516 while ((cp = strtok(NULL, WHITESPACE))) { |
509 if (options->num_allow_users >= MAX_ALLOW_USERS) { 510 fprintf(stderr, "%s line %d: too many allow users.\n", 511 filename, linenum); 512 exit(1); 513 } | 517 if (options->num_allow_users >= MAX_ALLOW_USERS) 518 fatal("%.200s line %d: too many allow users.\n", filename, 519 linenum); |
514 options->allow_users[options->num_allow_users++] = xstrdup(cp); 515 } 516 break; 517 518 case sDenyUsers: 519 while ((cp = strtok(NULL, WHITESPACE))) { | 520 options->allow_users[options->num_allow_users++] = xstrdup(cp); 521 } 522 break; 523 524 case sDenyUsers: 525 while ((cp = strtok(NULL, WHITESPACE))) { |
520 if (options->num_deny_users >= MAX_DENY_USERS) { 521 fprintf(stderr, "%s line %d: too many deny users.\n", 522 filename, linenum); 523 exit(1); 524 } | 526 if (options->num_deny_users >= MAX_DENY_USERS) 527 fatal("%.200s line %d: too many deny users.\n", filename, 528 linenum); |
525 options->deny_users[options->num_deny_users++] = xstrdup(cp); 526 } 527 break; 528 529 case sAllowGroups: 530 while ((cp = strtok(NULL, WHITESPACE))) { | 529 options->deny_users[options->num_deny_users++] = xstrdup(cp); 530 } 531 break; 532 533 case sAllowGroups: 534 while ((cp = strtok(NULL, WHITESPACE))) { |
531 if (options->num_allow_groups >= MAX_ALLOW_GROUPS) { 532 fprintf(stderr, "%s line %d: too many allow groups.\n", 533 filename, linenum); 534 exit(1); 535 } | 535 if (options->num_allow_groups >= MAX_ALLOW_GROUPS) 536 fatal("%.200s line %d: too many allow groups.\n", filename, 537 linenum); |
536 options->allow_groups[options->num_allow_groups++] = xstrdup(cp); 537 } 538 break; 539 540 case sDenyGroups: 541 while ((cp = strtok(NULL, WHITESPACE))) { | 538 options->allow_groups[options->num_allow_groups++] = xstrdup(cp); 539 } 540 break; 541 542 case sDenyGroups: 543 while ((cp = strtok(NULL, WHITESPACE))) { |
542 if (options->num_deny_groups >= MAX_DENY_GROUPS) { 543 fprintf(stderr, "%s line %d: too many deny groups.\n", 544 filename, linenum); 545 exit(1); 546 } | 544 if (options->num_deny_groups >= MAX_DENY_GROUPS) 545 fatal("%.200s line %d: too many deny groups.\n", filename, 546 linenum); |
547 options->deny_groups[options->num_deny_groups++] = xstrdup(cp); 548 } 549 break; 550 | 547 options->deny_groups[options->num_deny_groups++] = xstrdup(cp); 548 } 549 break; 550 |
551 case sConnectionsPerPeriod: 552 cp = strtok(NULL, WHITESPACE); 553 if (cp == NULL) 554 fatal("%.200s line %d: missing (>= 0) number argument.\n", 555 filename, linenum); 556 if (sscanf(cp, " %u/%u ", &options->connections_per_period, 557 &options->connections_period) != 2) 558 fatal("%.200s line %d: invalid numerical argument(s).\n", 559 filename, linenum); 560 if (options->connections_per_period != 0 && 561 options->connections_period == 0) 562 fatal("%.200s line %d: invalid connections period.\n", 563 filename, linenum); 564 break; 565 |
|
551 default: | 566 default: |
552 fprintf(stderr, "%s line %d: Missing handler for opcode %s (%d)\n", | 567 fatal("%.200s line %d: Missing handler for opcode %s (%d)\n", |
553 filename, linenum, cp, opcode); | 568 filename, linenum, cp, opcode); |
554 exit(1); | |
555 } | 569 } |
556 if (strtok(NULL, WHITESPACE) != NULL) { 557 fprintf(stderr, "%s line %d: garbage at end of line.\n", 558 filename, linenum); 559 exit(1); 560 } | 570 if (strtok(NULL, WHITESPACE) != NULL) 571 fatal("%.200s line %d: garbage at end of line.\n", filename, 572 linenum); |
561 } 562 fclose(f); | 573 } 574 fclose(f); |
563 if (bad_options > 0) { 564 fprintf(stderr, "%s: terminating, %d bad configuration options\n", | 575 if (bad_options > 0) 576 fatal("%.200s: terminating, %d bad configuration options\n", |
565 filename, bad_options); | 577 filename, bad_options); |
566 exit(1); 567 } | |
568} | 578} |