diff options
author | Damien Miller <djm@mindrot.org> | 1999-11-15 15:25:10 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 1999-11-15 15:25:10 +1100 |
commit | 2ccf661cbe0924a1549a74b5a4f970e90f94d6a9 (patch) | |
tree | 8bb7ea3cbe9d473e7f46b7084f563cc593cc5d47 /readconf.c | |
parent | cedfecc99e73f9661d4dc3cea8c88e57c6e0b487 (diff) |
- Merged more OpenBSD CVS changes:
[auth-krb4.c]
- disconnect if getpeername() fails
- missing xfree(*client)
[canohost.c]
- disconnect if getpeername() fails
- fix comment: we _do_ disconnect if ip-options are set
[sshd.c]
- disconnect if getpeername() fails
- move checking of remote port to central place
[auth-rhosts.c] move checking of remote port to central place
[log-server.c] avoid extra fd per sshd, from millert@
[readconf.c] print _all_ bad config-options in ssh(1), too
[readconf.h] print _all_ bad config-options in ssh(1), too
[ssh.c] print _all_ bad config-options in ssh(1), too
[sshconnect.c] disconnect if getpeername() fails
- OpenBSD's changes to sshd.c broke the PAM stuff, re-merged it.
Diffstat (limited to 'readconf.c')
-rw-r--r-- | readconf.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/readconf.c b/readconf.c index 2a99266aa..b341322c8 100644 --- a/readconf.c +++ b/readconf.c | |||
@@ -14,7 +14,7 @@ Functions for reading the configuration files. | |||
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include "includes.h" | 16 | #include "includes.h" |
17 | RCSID("$Id: readconf.c,v 1.2 1999/11/11 06:57:39 damien Exp $"); | 17 | RCSID("$Id: readconf.c,v 1.3 1999/11/15 04:25:10 damien Exp $"); |
18 | 18 | ||
19 | #include "ssh.h" | 19 | #include "ssh.h" |
20 | #include "cipher.h" | 20 | #include "cipher.h" |
@@ -88,6 +88,7 @@ RCSID("$Id: readconf.c,v 1.2 1999/11/11 06:57:39 damien Exp $"); | |||
88 | 88 | ||
89 | typedef enum | 89 | typedef enum |
90 | { | 90 | { |
91 | oBadOption, | ||
91 | oForwardAgent, oForwardX11, oGatewayPorts, oRhostsAuthentication, | 92 | oForwardAgent, oForwardX11, oGatewayPorts, oRhostsAuthentication, |
92 | oPasswordAuthentication, oRSAAuthentication, oFallBackToRsh, oUseRsh, | 93 | oPasswordAuthentication, oRSAAuthentication, oFallBackToRsh, oUseRsh, |
93 | #ifdef KRB4 | 94 | #ifdef KRB4 |
@@ -222,16 +223,16 @@ static OpCodes parse_token(const char *cp, const char *filename, int linenum) | |||
222 | if (strcmp(cp, keywords[i].name) == 0) | 223 | if (strcmp(cp, keywords[i].name) == 0) |
223 | return keywords[i].opcode; | 224 | return keywords[i].opcode; |
224 | 225 | ||
225 | fatal("%.200s line %d: Bad configuration option.", | 226 | fprintf(stderr, "%s: line %d: Bad configuration option: %s\n", |
226 | filename, linenum); | 227 | filename, linenum, cp); |
227 | /*NOTREACHED*/ | 228 | return oBadOption; |
228 | return 0; | ||
229 | } | 229 | } |
230 | 230 | ||
231 | /* Processes a single option line as used in the configuration files. | 231 | /* Processes a single option line as used in the configuration files. |
232 | This only sets those values that have not already been set. */ | 232 | This only sets those values that have not already been set. */ |
233 | 233 | ||
234 | void process_config_line(Options *options, const char *host, | 234 | int |
235 | process_config_line(Options *options, const char *host, | ||
235 | char *line, const char *filename, int linenum, | 236 | char *line, const char *filename, int linenum, |
236 | int *activep) | 237 | int *activep) |
237 | { | 238 | { |
@@ -241,7 +242,7 @@ void process_config_line(Options *options, const char *host, | |||
241 | /* Skip leading whitespace. */ | 242 | /* Skip leading whitespace. */ |
242 | cp = line + strspn(line, WHITESPACE); | 243 | cp = line + strspn(line, WHITESPACE); |
243 | if (!*cp || *cp == '\n' || *cp == '#') | 244 | if (!*cp || *cp == '\n' || *cp == '#') |
244 | return; | 245 | return 0; |
245 | 246 | ||
246 | /* Get the keyword. (Each line is supposed to begin with a keyword). */ | 247 | /* Get the keyword. (Each line is supposed to begin with a keyword). */ |
247 | cp = strtok(cp, WHITESPACE); | 248 | cp = strtok(cp, WHITESPACE); |
@@ -256,7 +257,9 @@ void process_config_line(Options *options, const char *host, | |||
256 | 257 | ||
257 | switch (opcode) | 258 | switch (opcode) |
258 | { | 259 | { |
259 | 260 | case oBadOption: | |
261 | return -1; /* don't panic, but count bad options */ | ||
262 | /*NOTREACHED*/ | ||
260 | case oForwardAgent: | 263 | case oForwardAgent: |
261 | intptr = &options->forward_agent; | 264 | intptr = &options->forward_agent; |
262 | parse_flag: | 265 | parse_flag: |
@@ -426,7 +429,7 @@ void process_config_line(Options *options, const char *host, | |||
426 | *charptr = string; | 429 | *charptr = string; |
427 | else | 430 | else |
428 | xfree(string); | 431 | xfree(string); |
429 | return; | 432 | return 0; |
430 | 433 | ||
431 | case oPort: | 434 | case oPort: |
432 | intptr = &options->port; | 435 | intptr = &options->port; |
@@ -533,7 +536,7 @@ void process_config_line(Options *options, const char *host, | |||
533 | break; | 536 | break; |
534 | } | 537 | } |
535 | /* Avoid garbage check below, as strtok already returned NULL. */ | 538 | /* Avoid garbage check below, as strtok already returned NULL. */ |
536 | return; | 539 | return 0; |
537 | 540 | ||
538 | case oEscapeChar: | 541 | case oEscapeChar: |
539 | intptr = &options->escape_char; | 542 | intptr = &options->escape_char; |
@@ -561,13 +564,14 @@ void process_config_line(Options *options, const char *host, | |||
561 | break; | 564 | break; |
562 | 565 | ||
563 | default: | 566 | default: |
564 | fatal("parse_config_file: Unimplemented opcode %d", opcode); | 567 | fatal("process_config_line: Unimplemented opcode %d", opcode); |
565 | } | 568 | } |
566 | 569 | ||
567 | /* Check that there is no garbage at end of line. */ | 570 | /* Check that there is no garbage at end of line. */ |
568 | if (strtok(NULL, WHITESPACE) != NULL) | 571 | if (strtok(NULL, WHITESPACE) != NULL) |
569 | fatal("%.200s line %d: garbage at end of line.", | 572 | fatal("%.200s line %d: garbage at end of line.", |
570 | filename, linenum); | 573 | filename, linenum); |
574 | return 0; | ||
571 | } | 575 | } |
572 | 576 | ||
573 | 577 | ||
@@ -580,6 +584,7 @@ void read_config_file(const char *filename, const char *host, Options *options) | |||
580 | FILE *f; | 584 | FILE *f; |
581 | char line[1024]; | 585 | char line[1024]; |
582 | int active, linenum; | 586 | int active, linenum; |
587 | int bad_options = 0; | ||
583 | 588 | ||
584 | /* Open the file. */ | 589 | /* Open the file. */ |
585 | f = fopen(filename, "r"); | 590 | f = fopen(filename, "r"); |
@@ -596,10 +601,13 @@ void read_config_file(const char *filename, const char *host, Options *options) | |||
596 | { | 601 | { |
597 | /* Update line number counter. */ | 602 | /* Update line number counter. */ |
598 | linenum++; | 603 | linenum++; |
599 | 604 | if (process_config_line(options, host, line, filename, linenum, &active) != 0) | |
600 | process_config_line(options, host, line, filename, linenum, &active); | 605 | bad_options++; |
601 | } | 606 | } |
602 | fclose(f); | 607 | fclose(f); |
608 | if (bad_options > 0) | ||
609 | fatal("%s: terminating, %d bad configuration options\n", | ||
610 | filename, bad_options); | ||
603 | } | 611 | } |
604 | 612 | ||
605 | /* Initializes options to special values that indicate that they have not | 613 | /* Initializes options to special values that indicate that they have not |