diff options
Diffstat (limited to 'readconf.c')
-rw-r--r-- | readconf.c | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/readconf.c b/readconf.c index c514e9b59..06cfaa1a3 100644 --- a/readconf.c +++ b/readconf.c | |||
@@ -14,7 +14,7 @@ | |||
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include "includes.h" | 16 | #include "includes.h" |
17 | RCSID("$OpenBSD: readconf.c,v 1.41 2000/07/11 19:17:44 deraadt Exp $"); | 17 | RCSID("$OpenBSD: readconf.c,v 1.43 2000/07/14 22:59:46 markus Exp $"); |
18 | 18 | ||
19 | #include "ssh.h" | 19 | #include "ssh.h" |
20 | #include "cipher.h" | 20 | #include "cipher.h" |
@@ -164,10 +164,6 @@ static struct { | |||
164 | { NULL, 0 } | 164 | { NULL, 0 } |
165 | }; | 165 | }; |
166 | 166 | ||
167 | /* Characters considered whitespace in strsep calls. */ | ||
168 | #define WHITESPACE " \t\r\n=" | ||
169 | |||
170 | |||
171 | /* | 167 | /* |
172 | * Adds a local TCP/IP port forward to options. Never returns if there is an | 168 | * Adds a local TCP/IP port forward to options. Never returns if there is an |
173 | * error. | 169 | * error. |
@@ -241,13 +237,15 @@ process_config_line(Options *options, const char *host, | |||
241 | int opcode, *intptr, value; | 237 | int opcode, *intptr, value; |
242 | u_short fwd_port, fwd_host_port; | 238 | u_short fwd_port, fwd_host_port; |
243 | 239 | ||
244 | /* Skip leading whitespace. */ | 240 | s = line; |
245 | s = line + strspn(line, WHITESPACE); | 241 | /* Get the keyword. (Each line is supposed to begin with a keyword). */ |
246 | if (!*s || *s == '\n' || *s == '#') | 242 | keyword = strdelim(&s); |
243 | /* Ignore leading whitespace. */ | ||
244 | if (*keyword == '\0') | ||
245 | keyword = strdelim(&s); | ||
246 | if (!*keyword || *keyword == '\n' || *keyword == '#') | ||
247 | return 0; | 247 | return 0; |
248 | 248 | ||
249 | /* Get the keyword. (Each line is supposed to begin with a keyword). */ | ||
250 | keyword = strsep(&s, WHITESPACE); | ||
251 | opcode = parse_token(keyword, filename, linenum); | 249 | opcode = parse_token(keyword, filename, linenum); |
252 | 250 | ||
253 | switch (opcode) { | 251 | switch (opcode) { |
@@ -258,7 +256,7 @@ process_config_line(Options *options, const char *host, | |||
258 | case oForwardAgent: | 256 | case oForwardAgent: |
259 | intptr = &options->forward_agent; | 257 | intptr = &options->forward_agent; |
260 | parse_flag: | 258 | parse_flag: |
261 | arg = strsep(&s, WHITESPACE); | 259 | arg = strdelim(&s); |
262 | if (!arg || *arg == '\0') | 260 | if (!arg || *arg == '\0') |
263 | fatal("%.200s line %d: Missing yes/no argument.", filename, linenum); | 261 | fatal("%.200s line %d: Missing yes/no argument.", filename, linenum); |
264 | value = 0; /* To avoid compiler warning... */ | 262 | value = 0; /* To avoid compiler warning... */ |
@@ -344,7 +342,7 @@ parse_flag: | |||
344 | 342 | ||
345 | case oStrictHostKeyChecking: | 343 | case oStrictHostKeyChecking: |
346 | intptr = &options->strict_host_key_checking; | 344 | intptr = &options->strict_host_key_checking; |
347 | arg = strsep(&s, WHITESPACE); | 345 | arg = strdelim(&s); |
348 | if (!arg || *arg == '\0') | 346 | if (!arg || *arg == '\0') |
349 | fatal("%.200s line %d: Missing yes/no argument.", | 347 | fatal("%.200s line %d: Missing yes/no argument.", |
350 | filename, linenum); | 348 | filename, linenum); |
@@ -379,7 +377,7 @@ parse_flag: | |||
379 | 377 | ||
380 | case oIdentityFile: | 378 | case oIdentityFile: |
381 | case oIdentityFile2: | 379 | case oIdentityFile2: |
382 | arg = strsep(&s, WHITESPACE); | 380 | arg = strdelim(&s); |
383 | if (!arg || *arg == '\0') | 381 | if (!arg || *arg == '\0') |
384 | fatal("%.200s line %d: Missing argument.", filename, linenum); | 382 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
385 | if (*activep) { | 383 | if (*activep) { |
@@ -404,7 +402,7 @@ parse_flag: | |||
404 | case oUser: | 402 | case oUser: |
405 | charptr = &options->user; | 403 | charptr = &options->user; |
406 | parse_string: | 404 | parse_string: |
407 | arg = strsep(&s, WHITESPACE); | 405 | arg = strdelim(&s); |
408 | if (!arg || *arg == '\0') | 406 | if (!arg || *arg == '\0') |
409 | fatal("%.200s line %d: Missing argument.", filename, linenum); | 407 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
410 | if (*activep && *charptr == NULL) | 408 | if (*activep && *charptr == NULL) |
@@ -434,7 +432,7 @@ parse_string: | |||
434 | case oProxyCommand: | 432 | case oProxyCommand: |
435 | charptr = &options->proxy_command; | 433 | charptr = &options->proxy_command; |
436 | string = xstrdup(""); | 434 | string = xstrdup(""); |
437 | while ((arg = strsep(&s, WHITESPACE)) != NULL && *arg != '\0') { | 435 | while ((arg = strdelim(&s)) != NULL && *arg != '\0') { |
438 | string = xrealloc(string, strlen(string) + strlen(arg) + 2); | 436 | string = xrealloc(string, strlen(string) + strlen(arg) + 2); |
439 | strcat(string, " "); | 437 | strcat(string, " "); |
440 | strcat(string, arg); | 438 | strcat(string, arg); |
@@ -448,7 +446,7 @@ parse_string: | |||
448 | case oPort: | 446 | case oPort: |
449 | intptr = &options->port; | 447 | intptr = &options->port; |
450 | parse_int: | 448 | parse_int: |
451 | arg = strsep(&s, WHITESPACE); | 449 | arg = strdelim(&s); |
452 | if (!arg || *arg == '\0') | 450 | if (!arg || *arg == '\0') |
453 | fatal("%.200s line %d: Missing argument.", filename, linenum); | 451 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
454 | if (arg[0] < '0' || arg[0] > '9') | 452 | if (arg[0] < '0' || arg[0] > '9') |
@@ -468,7 +466,7 @@ parse_int: | |||
468 | 466 | ||
469 | case oCipher: | 467 | case oCipher: |
470 | intptr = &options->cipher; | 468 | intptr = &options->cipher; |
471 | arg = strsep(&s, WHITESPACE); | 469 | arg = strdelim(&s); |
472 | if (!arg || *arg == '\0') | 470 | if (!arg || *arg == '\0') |
473 | fatal("%.200s line %d: Missing argument.", filename, linenum); | 471 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
474 | value = cipher_number(arg); | 472 | value = cipher_number(arg); |
@@ -480,7 +478,7 @@ parse_int: | |||
480 | break; | 478 | break; |
481 | 479 | ||
482 | case oCiphers: | 480 | case oCiphers: |
483 | arg = strsep(&s, WHITESPACE); | 481 | arg = strdelim(&s); |
484 | if (!arg || *arg == '\0') | 482 | if (!arg || *arg == '\0') |
485 | fatal("%.200s line %d: Missing argument.", filename, linenum); | 483 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
486 | if (!ciphers_valid(arg)) | 484 | if (!ciphers_valid(arg)) |
@@ -492,7 +490,7 @@ parse_int: | |||
492 | 490 | ||
493 | case oProtocol: | 491 | case oProtocol: |
494 | intptr = &options->protocol; | 492 | intptr = &options->protocol; |
495 | arg = strsep(&s, WHITESPACE); | 493 | arg = strdelim(&s); |
496 | if (!arg || *arg == '\0') | 494 | if (!arg || *arg == '\0') |
497 | fatal("%.200s line %d: Missing argument.", filename, linenum); | 495 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
498 | value = proto_spec(arg); | 496 | value = proto_spec(arg); |
@@ -505,7 +503,7 @@ parse_int: | |||
505 | 503 | ||
506 | case oLogLevel: | 504 | case oLogLevel: |
507 | intptr = (int *) &options->log_level; | 505 | intptr = (int *) &options->log_level; |
508 | arg = strsep(&s, WHITESPACE); | 506 | arg = strdelim(&s); |
509 | value = log_level_number(arg); | 507 | value = log_level_number(arg); |
510 | if (value == (LogLevel) - 1) | 508 | if (value == (LogLevel) - 1) |
511 | fatal("%.200s line %d: unsupported log level '%s'\n", | 509 | fatal("%.200s line %d: unsupported log level '%s'\n", |
@@ -515,14 +513,14 @@ parse_int: | |||
515 | break; | 513 | break; |
516 | 514 | ||
517 | case oRemoteForward: | 515 | case oRemoteForward: |
518 | arg = strsep(&s, WHITESPACE); | 516 | arg = strdelim(&s); |
519 | if (!arg || *arg == '\0') | 517 | if (!arg || *arg == '\0') |
520 | fatal("%.200s line %d: Missing argument.", filename, linenum); | 518 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
521 | if (arg[0] < '0' || arg[0] > '9') | 519 | if (arg[0] < '0' || arg[0] > '9') |
522 | fatal("%.200s line %d: Badly formatted port number.", | 520 | fatal("%.200s line %d: Badly formatted port number.", |
523 | filename, linenum); | 521 | filename, linenum); |
524 | fwd_port = atoi(arg); | 522 | fwd_port = atoi(arg); |
525 | arg = strsep(&s, WHITESPACE); | 523 | arg = strdelim(&s); |
526 | if (!arg || *arg == '\0') | 524 | if (!arg || *arg == '\0') |
527 | fatal("%.200s line %d: Missing second argument.", | 525 | fatal("%.200s line %d: Missing second argument.", |
528 | filename, linenum); | 526 | filename, linenum); |
@@ -534,14 +532,14 @@ parse_int: | |||
534 | break; | 532 | break; |
535 | 533 | ||
536 | case oLocalForward: | 534 | case oLocalForward: |
537 | arg = strsep(&s, WHITESPACE); | 535 | arg = strdelim(&s); |
538 | if (!arg || *arg == '\0') | 536 | if (!arg || *arg == '\0') |
539 | fatal("%.200s line %d: Missing argument.", filename, linenum); | 537 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
540 | if (arg[0] < '0' || arg[0] > '9') | 538 | if (arg[0] < '0' || arg[0] > '9') |
541 | fatal("%.200s line %d: Badly formatted port number.", | 539 | fatal("%.200s line %d: Badly formatted port number.", |
542 | filename, linenum); | 540 | filename, linenum); |
543 | fwd_port = atoi(arg); | 541 | fwd_port = atoi(arg); |
544 | arg = strsep(&s, WHITESPACE); | 542 | arg = strdelim(&s); |
545 | if (!arg || *arg == '\0') | 543 | if (!arg || *arg == '\0') |
546 | fatal("%.200s line %d: Missing second argument.", | 544 | fatal("%.200s line %d: Missing second argument.", |
547 | filename, linenum); | 545 | filename, linenum); |
@@ -554,18 +552,18 @@ parse_int: | |||
554 | 552 | ||
555 | case oHost: | 553 | case oHost: |
556 | *activep = 0; | 554 | *activep = 0; |
557 | while ((arg = strsep(&s, WHITESPACE)) != NULL && *arg != '\0') | 555 | while ((arg = strdelim(&s)) != NULL && *arg != '\0') |
558 | if (match_pattern(host, arg)) { | 556 | if (match_pattern(host, arg)) { |
559 | debug("Applying options for %.100s", arg); | 557 | debug("Applying options for %.100s", arg); |
560 | *activep = 1; | 558 | *activep = 1; |
561 | break; | 559 | break; |
562 | } | 560 | } |
563 | /* Avoid garbage check below, as strsep is done. */ | 561 | /* Avoid garbage check below, as strdelim is done. */ |
564 | return 0; | 562 | return 0; |
565 | 563 | ||
566 | case oEscapeChar: | 564 | case oEscapeChar: |
567 | intptr = &options->escape_char; | 565 | intptr = &options->escape_char; |
568 | arg = strsep(&s, WHITESPACE); | 566 | arg = strdelim(&s); |
569 | if (!arg || *arg == '\0') | 567 | if (!arg || *arg == '\0') |
570 | fatal("%.200s line %d: Missing argument.", filename, linenum); | 568 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
571 | if (arg[0] == '^' && arg[2] == 0 && | 569 | if (arg[0] == '^' && arg[2] == 0 && |
@@ -590,7 +588,7 @@ parse_int: | |||
590 | } | 588 | } |
591 | 589 | ||
592 | /* Check that there is no garbage at end of line. */ | 590 | /* Check that there is no garbage at end of line. */ |
593 | if ((arg = strsep(&s, WHITESPACE)) != NULL && *arg != '\0') | 591 | if ((arg = strdelim(&s)) != NULL && *arg != '\0') |
594 | { | 592 | { |
595 | fatal("%.200s line %d: garbage at end of line; \"%.200s\".", | 593 | fatal("%.200s line %d: garbage at end of line; \"%.200s\".", |
596 | filename, linenum, arg); | 594 | filename, linenum, arg); |