summaryrefslogtreecommitdiff
path: root/servconf.c
diff options
context:
space:
mode:
Diffstat (limited to 'servconf.c')
-rw-r--r--servconf.c67
1 files changed, 43 insertions, 24 deletions
diff --git a/servconf.c b/servconf.c
index 800c4d5f4..918fb8ed2 100644
--- a/servconf.c
+++ b/servconf.c
@@ -12,11 +12,12 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$Id: servconf.c,v 1.10 2000/04/12 08:45:06 damien Exp $"); 15RCSID("$Id: servconf.c,v 1.11 2000/04/12 10:17:40 damien Exp $");
16 16
17#include "ssh.h" 17#include "ssh.h"
18#include "servconf.h" 18#include "servconf.h"
19#include "xmalloc.h" 19#include "xmalloc.h"
20#include "compat.h"
20 21
21/* add listen address */ 22/* add listen address */
22void add_listen_addr(ServerOptions *options, char *addr); 23void add_listen_addr(ServerOptions *options, char *addr);
@@ -68,6 +69,8 @@ initialize_server_options(ServerOptions *options)
68 options->num_deny_users = 0; 69 options->num_deny_users = 0;
69 options->num_allow_groups = 0; 70 options->num_allow_groups = 0;
70 options->num_deny_groups = 0; 71 options->num_deny_groups = 0;
72 options->ciphers = NULL;
73 options->protocol = SSH_PROTO_UNKNOWN;
71} 74}
72 75
73void 76void
@@ -139,6 +142,8 @@ fill_default_server_options(ServerOptions *options)
139 options->permit_empty_passwd = 0; 142 options->permit_empty_passwd = 0;
140 if (options->use_login == -1) 143 if (options->use_login == -1)
141 options->use_login = 0; 144 options->use_login = 0;
145 if (options->protocol == SSH_PROTO_UNKNOWN)
146 options->protocol = SSH_PROTO_1;
142} 147}
143 148
144#define WHITESPACE " \t\r\n" 149#define WHITESPACE " \t\r\n"
@@ -162,7 +167,7 @@ typedef enum {
162 sPrintMotd, sIgnoreRhosts, sX11Forwarding, sX11DisplayOffset, 167 sPrintMotd, sIgnoreRhosts, sX11Forwarding, sX11DisplayOffset,
163 sStrictModes, sEmptyPasswd, sRandomSeedFile, sKeepAlives, sCheckMail, 168 sStrictModes, sEmptyPasswd, sRandomSeedFile, sKeepAlives, sCheckMail,
164 sUseLogin, sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups, 169 sUseLogin, sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
165 sIgnoreUserKnownHosts, sDSAKeyFile 170 sIgnoreUserKnownHosts, sDSAKeyFile, sCiphers, sProtocol
166} ServerOpCodes; 171} ServerOpCodes;
167 172
168/* Textual representation of the tokens. */ 173/* Textual representation of the tokens. */
@@ -211,6 +216,8 @@ static struct {
211 { "denyusers", sDenyUsers }, 216 { "denyusers", sDenyUsers },
212 { "allowgroups", sAllowGroups }, 217 { "allowgroups", sAllowGroups },
213 { "denygroups", sDenyGroups }, 218 { "denygroups", sDenyGroups },
219 { "ciphers", sCiphers },
220 { "protocol", sProtocol },
214 { NULL, 0 } 221 { NULL, 0 }
215}; 222};
216 223
@@ -494,7 +501,7 @@ parse_flag:
494 value = log_facility_number(cp); 501 value = log_facility_number(cp);
495 if (value == (SyslogFacility) - 1) 502 if (value == (SyslogFacility) - 1)
496 fatal("%.200s line %d: unsupported log facility '%s'\n", 503 fatal("%.200s line %d: unsupported log facility '%s'\n",
497 filename, linenum, cp ? cp : "<NONE>"); 504 filename, linenum, cp ? cp : "<NONE>");
498 if (*intptr == -1) 505 if (*intptr == -1)
499 *intptr = (SyslogFacility) value; 506 *intptr = (SyslogFacility) value;
500 break; 507 break;
@@ -505,55 +512,67 @@ parse_flag:
505 value = log_level_number(cp); 512 value = log_level_number(cp);
506 if (value == (LogLevel) - 1) 513 if (value == (LogLevel) - 1)
507 fatal("%.200s line %d: unsupported log level '%s'\n", 514 fatal("%.200s line %d: unsupported log level '%s'\n",
508 filename, linenum, cp ? cp : "<NONE>"); 515 filename, linenum, cp ? cp : "<NONE>");
509 if (*intptr == -1) 516 if (*intptr == -1)
510 *intptr = (LogLevel) value; 517 *intptr = (LogLevel) value;
511 break; 518 break;
512 519
513 case sAllowUsers: 520 case sAllowUsers:
514 while ((cp = strtok(NULL, WHITESPACE))) { 521 while ((cp = strtok(NULL, WHITESPACE))) {
515 if (options->num_allow_users >= MAX_ALLOW_USERS) { 522 if (options->num_allow_users >= MAX_ALLOW_USERS)
516 fprintf(stderr, "%s line %d: too many allow users.\n", 523 fatal("%s line %d: too many allow users.\n",
517 filename, linenum); 524 filename, linenum);
518 exit(1);
519 }
520 options->allow_users[options->num_allow_users++] = xstrdup(cp); 525 options->allow_users[options->num_allow_users++] = xstrdup(cp);
521 } 526 }
522 break; 527 break;
523 528
524 case sDenyUsers: 529 case sDenyUsers:
525 while ((cp = strtok(NULL, WHITESPACE))) { 530 while ((cp = strtok(NULL, WHITESPACE))) {
526 if (options->num_deny_users >= MAX_DENY_USERS) { 531 if (options->num_deny_users >= MAX_DENY_USERS)
527 fprintf(stderr, "%s line %d: too many deny users.\n", 532 fatal( "%s line %d: too many deny users.\n",
528 filename, linenum); 533 filename, linenum);
529 exit(1);
530 }
531 options->deny_users[options->num_deny_users++] = xstrdup(cp); 534 options->deny_users[options->num_deny_users++] = xstrdup(cp);
532 } 535 }
533 break; 536 break;
534 537
535 case sAllowGroups: 538 case sAllowGroups:
536 while ((cp = strtok(NULL, WHITESPACE))) { 539 while ((cp = strtok(NULL, WHITESPACE))) {
537 if (options->num_allow_groups >= MAX_ALLOW_GROUPS) { 540 if (options->num_allow_groups >= MAX_ALLOW_GROUPS)
538 fprintf(stderr, "%s line %d: too many allow groups.\n", 541 fatal("%s line %d: too many allow groups.\n",
539 filename, linenum); 542 filename, linenum);
540 exit(1);
541 }
542 options->allow_groups[options->num_allow_groups++] = xstrdup(cp); 543 options->allow_groups[options->num_allow_groups++] = xstrdup(cp);
543 } 544 }
544 break; 545 break;
545 546
546 case sDenyGroups: 547 case sDenyGroups:
547 while ((cp = strtok(NULL, WHITESPACE))) { 548 while ((cp = strtok(NULL, WHITESPACE))) {
548 if (options->num_deny_groups >= MAX_DENY_GROUPS) { 549 if (options->num_deny_groups >= MAX_DENY_GROUPS)
549 fprintf(stderr, "%s line %d: too many deny groups.\n", 550 fatal("%s line %d: too many deny groups.\n",
550 filename, linenum); 551 filename, linenum);
551 exit(1);
552 }
553 options->deny_groups[options->num_deny_groups++] = xstrdup(cp); 552 options->deny_groups[options->num_deny_groups++] = xstrdup(cp);
554 } 553 }
555 break; 554 break;
556 555
556 case sCiphers:
557 cp = strtok(NULL, WHITESPACE);
558 if (!ciphers_valid(cp))
559 fatal("%s line %d: Bad cipher spec '%s'.",
560 filename, linenum, cp ? cp : "<NONE>");
561 if (options->ciphers == NULL)
562 options->ciphers = xstrdup(cp);
563 break;
564
565 case sProtocol:
566 intptr = &options->protocol;
567 cp = strtok(NULL, WHITESPACE);
568 value = proto_spec(cp);
569 if (value == SSH_PROTO_UNKNOWN)
570 fatal("%s line %d: Bad protocol spec '%s'.",
571 filename, linenum, cp ? cp : "<NONE>");
572 if (*intptr == SSH_PROTO_UNKNOWN)
573 *intptr = value;
574 break;
575
557 default: 576 default:
558 fprintf(stderr, "%s line %d: Missing handler for opcode %s (%d)\n", 577 fprintf(stderr, "%s line %d: Missing handler for opcode %s (%d)\n",
559 filename, linenum, cp, opcode); 578 filename, linenum, cp, opcode);