|
Lines 476-482
execute_in_shell(const char *cmd)
Link Here
|
| 476 |
*/ |
476 |
*/ |
| 477 |
static int |
477 |
static int |
| 478 |
match_cfg_line(Options *options, char **condition, struct passwd *pw, |
478 |
match_cfg_line(Options *options, char **condition, struct passwd *pw, |
| 479 |
const char *host_arg, const char *filename, int linenum) |
479 |
const char *original_host, int post_canon, |
|
|
480 |
const char *filename, int linenum) |
| 480 |
{ |
481 |
{ |
| 481 |
char *arg, *attrib, *cmd, *cp = *condition, *host; |
482 |
char *arg, *attrib, *cmd, *cp = *condition, *host; |
| 482 |
const char *ruser; |
483 |
const char *ruser; |
|
Lines 493-505
match_cfg_line(Options *options, char **
Link Here
|
| 493 |
if (options->hostname != NULL) { |
494 |
if (options->hostname != NULL) { |
| 494 |
/* NB. Please keep in sync with ssh.c:main() */ |
495 |
/* NB. Please keep in sync with ssh.c:main() */ |
| 495 |
host = percent_expand(options->hostname, |
496 |
host = percent_expand(options->hostname, |
| 496 |
"h", host_arg, (char *)NULL); |
497 |
"h", original_host, (char *)NULL); |
| 497 |
} else |
498 |
} else |
| 498 |
host = xstrdup(host_arg); |
499 |
host = xstrdup(original_host); |
| 499 |
|
500 |
|
| 500 |
debug3("checking match for '%s' host %s", cp, host); |
501 |
debug3("checking match for '%s' host %s", cp, host); |
| 501 |
while ((attrib = strdelim(&cp)) && *attrib != '\0') { |
502 |
while ((attrib = strdelim(&cp)) && *attrib != '\0') { |
| 502 |
attributes++; |
503 |
attributes++; |
|
|
504 |
/* criteria "all" and "canonical" have no argument */ |
| 503 |
if (strcasecmp(attrib, "all") == 0) { |
505 |
if (strcasecmp(attrib, "all") == 0) { |
| 504 |
if (attributes != 1 || |
506 |
if (attributes != 1 || |
| 505 |
((arg = strdelim(&cp)) != NULL && *arg != '\0')) { |
507 |
((arg = strdelim(&cp)) != NULL && *arg != '\0')) { |
|
Lines 511-517
match_cfg_line(Options *options, char **
Link Here
|
| 511 |
*condition = cp; |
513 |
*condition = cp; |
| 512 |
result = 1; |
514 |
result = 1; |
| 513 |
goto out; |
515 |
goto out; |
|
|
516 |
} else if (strcasecmp(attrib, "canonical") == 0) { |
| 517 |
if (!post_canon) { |
| 518 |
result = 0; |
| 519 |
continue; |
| 520 |
} else |
| 521 |
debug("%.200s line %d: matched 'Canonical' ", |
| 522 |
filename, linenum); |
| 514 |
} |
523 |
} |
|
|
524 |
/* All other criteria require an argument */ |
| 515 |
if ((arg = strdelim(&cp)) == NULL || *arg == '\0') { |
525 |
if ((arg = strdelim(&cp)) == NULL || *arg == '\0') { |
| 516 |
error("Missing Match criteria for %s", attrib); |
526 |
error("Missing Match criteria for %s", attrib); |
| 517 |
result = -1; |
527 |
result = -1; |
|
Lines 525-536
match_cfg_line(Options *options, char **
Link Here
|
| 525 |
debug("%.200s line %d: matched 'Host %.100s' ", |
535 |
debug("%.200s line %d: matched 'Host %.100s' ", |
| 526 |
filename, linenum, host); |
536 |
filename, linenum, host); |
| 527 |
} else if (strcasecmp(attrib, "originalhost") == 0) { |
537 |
} else if (strcasecmp(attrib, "originalhost") == 0) { |
| 528 |
if (match_hostname(host_arg, arg, len) != 1) |
538 |
if (match_hostname(original_host, arg, len) != 1) |
| 529 |
result = 0; |
539 |
result = 0; |
| 530 |
else |
540 |
else |
| 531 |
debug("%.200s line %d: matched " |
541 |
debug("%.200s line %d: matched " |
| 532 |
"'OriginalHost %.100s' ", |
542 |
"'OriginalHost %.100s' ", |
| 533 |
filename, linenum, host_arg); |
543 |
filename, linenum, original_host); |
| 534 |
} else if (strcasecmp(attrib, "user") == 0) { |
544 |
} else if (strcasecmp(attrib, "user") == 0) { |
| 535 |
if (match_pattern_list(ruser, arg, len, 0) != 1) |
545 |
if (match_pattern_list(ruser, arg, len, 0) != 1) |
| 536 |
result = 0; |
546 |
result = 0; |
|
Lines 556-562
match_cfg_line(Options *options, char **
Link Here
|
| 556 |
"d", pw->pw_dir, |
566 |
"d", pw->pw_dir, |
| 557 |
"h", host, |
567 |
"h", host, |
| 558 |
"l", thishost, |
568 |
"l", thishost, |
| 559 |
"n", host_arg, |
569 |
"n", original_host, |
| 560 |
"p", portstr, |
570 |
"p", portstr, |
| 561 |
"r", ruser, |
571 |
"r", ruser, |
| 562 |
"u", pw->pw_name, |
572 |
"u", pw->pw_name, |
|
Lines 719-725
static const struct multistate multistat
Link Here
|
| 719 |
#define WHITESPACE " \t\r\n" |
729 |
#define WHITESPACE " \t\r\n" |
| 720 |
int |
730 |
int |
| 721 |
process_config_line(Options *options, struct passwd *pw, const char *host, |
731 |
process_config_line(Options *options, struct passwd *pw, const char *host, |
| 722 |
char *line, const char *filename, int linenum, int *activep, int userconfig) |
732 |
const char *original_host, char *line, const char *filename, |
|
|
733 |
int linenum, int *activep, int flags) |
| 723 |
{ |
734 |
{ |
| 724 |
char *s, **charptr, *endofnumber, *keyword, *arg, *arg2; |
735 |
char *s, **charptr, *endofnumber, *keyword, *arg, *arg2; |
| 725 |
char **cpptr, fwdarg[256]; |
736 |
char **cpptr, fwdarg[256]; |
|
Lines 947-953
parse_time:
Link Here
|
| 947 |
if (*intptr >= SSH_MAX_IDENTITY_FILES) |
958 |
if (*intptr >= SSH_MAX_IDENTITY_FILES) |
| 948 |
fatal("%.200s line %d: Too many identity files specified (max %d).", |
959 |
fatal("%.200s line %d: Too many identity files specified (max %d).", |
| 949 |
filename, linenum, SSH_MAX_IDENTITY_FILES); |
960 |
filename, linenum, SSH_MAX_IDENTITY_FILES); |
| 950 |
add_identity_file(options, NULL, arg, userconfig); |
961 |
add_identity_file(options, NULL, |
|
|
962 |
arg, flags & SSHCONF_USERCONF); |
| 951 |
} |
963 |
} |
| 952 |
break; |
964 |
break; |
| 953 |
|
965 |
|
|
Lines 1195-1202
parse_int:
Link Here
|
| 1195 |
if (cmdline) |
1207 |
if (cmdline) |
| 1196 |
fatal("Host directive not supported as a command-line " |
1208 |
fatal("Host directive not supported as a command-line " |
| 1197 |
"option"); |
1209 |
"option"); |
| 1198 |
value = match_cfg_line(options, &s, pw, host, |
1210 |
value = match_cfg_line(options, &s, pw, original_host, |
| 1199 |
filename, linenum); |
1211 |
flags & SSHCONF_POSTCANON, filename, linenum); |
| 1200 |
if (value < 0) |
1212 |
if (value < 0) |
| 1201 |
fatal("%.200s line %d: Bad Match condition", filename, |
1213 |
fatal("%.200s line %d: Bad Match condition", filename, |
| 1202 |
linenum); |
1214 |
linenum); |
|
Lines 1444-1450
parse_int:
Link Here
|
| 1444 |
return 0; |
1456 |
return 0; |
| 1445 |
|
1457 |
|
| 1446 |
default: |
1458 |
default: |
| 1447 |
fatal("process_config_line: Unimplemented opcode %d", opcode); |
1459 |
fatal("%s: Unimplemented opcode %d", __func__, opcode); |
| 1448 |
} |
1460 |
} |
| 1449 |
|
1461 |
|
| 1450 |
/* Check that there is no garbage at end of line. */ |
1462 |
/* Check that there is no garbage at end of line. */ |
|
Lines 1464-1470
parse_int:
Link Here
|
| 1464 |
|
1476 |
|
| 1465 |
int |
1477 |
int |
| 1466 |
read_config_file(const char *filename, struct passwd *pw, const char *host, |
1478 |
read_config_file(const char *filename, struct passwd *pw, const char *host, |
| 1467 |
Options *options, int flags) |
1479 |
const char *original_host, Options *options, int flags) |
| 1468 |
{ |
1480 |
{ |
| 1469 |
FILE *f; |
1481 |
FILE *f; |
| 1470 |
char line[1024]; |
1482 |
char line[1024]; |
|
Lines 1495-1502
read_config_file(const char *filename, s
Link Here
|
| 1495 |
while (fgets(line, sizeof(line), f)) { |
1507 |
while (fgets(line, sizeof(line), f)) { |
| 1496 |
/* Update line number counter. */ |
1508 |
/* Update line number counter. */ |
| 1497 |
linenum++; |
1509 |
linenum++; |
| 1498 |
if (process_config_line(options, pw, host, line, filename, |
1510 |
if (process_config_line(options, pw, host, original_host, |
| 1499 |
linenum, &active, flags & SSHCONF_USERCONF) != 0) |
1511 |
line, filename, linenum, &active, flags) != 0) |
| 1500 |
bad_options++; |
1512 |
bad_options++; |
| 1501 |
} |
1513 |
} |
| 1502 |
fclose(f); |
1514 |
fclose(f); |