|
Lines 118-127
Link Here
|
| 118 |
|
118 |
|
| 119 |
static int read_config_file_depth(const char *filename, struct passwd *pw, |
119 |
static int read_config_file_depth(const char *filename, struct passwd *pw, |
| 120 |
const char *host, const char *original_host, Options *options, |
120 |
const char *host, const char *original_host, Options *options, |
| 121 |
int flags, int *activep, int depth); |
121 |
int flags, int *activep, int *want_final_pass, int depth); |
| 122 |
static int process_config_line_depth(Options *options, struct passwd *pw, |
122 |
static int process_config_line_depth(Options *options, struct passwd *pw, |
| 123 |
const char *host, const char *original_host, char *line, |
123 |
const char *host, const char *original_host, char *line, |
| 124 |
const char *filename, int linenum, int *activep, int flags, int depth); |
124 |
const char *filename, int linenum, int *activep, int flags, |
|
|
125 |
int *want_final_pass, int depth); |
| 125 |
|
126 |
|
| 126 |
/* Keyword tokens. */ |
127 |
/* Keyword tokens. */ |
| 127 |
|
128 |
|
|
Lines 524-531
execute_in_shell(const char *cmd)
Link Here
|
| 524 |
*/ |
525 |
*/ |
| 525 |
static int |
526 |
static int |
| 526 |
match_cfg_line(Options *options, char **condition, struct passwd *pw, |
527 |
match_cfg_line(Options *options, char **condition, struct passwd *pw, |
| 527 |
const char *host_arg, const char *original_host, int post_canon, |
528 |
const char *host_arg, const char *original_host, int final_pass, |
| 528 |
const char *filename, int linenum) |
529 |
int *want_final_pass, const char *filename, int linenum) |
| 529 |
{ |
530 |
{ |
| 530 |
char *arg, *oattrib, *attrib, *cmd, *cp = *condition, *host, *criteria; |
531 |
char *arg, *oattrib, *attrib, *cmd, *cp = *condition, *host, *criteria; |
| 531 |
const char *ruser; |
532 |
const char *ruser; |
|
Lines 539-545
match_cfg_line(Options *options, char **condition, struct passwd *pw,
Link Here
|
| 539 |
*/ |
540 |
*/ |
| 540 |
port = options->port <= 0 ? default_ssh_port() : options->port; |
541 |
port = options->port <= 0 ? default_ssh_port() : options->port; |
| 541 |
ruser = options->user == NULL ? pw->pw_name : options->user; |
542 |
ruser = options->user == NULL ? pw->pw_name : options->user; |
| 542 |
if (post_canon) { |
543 |
if (final_pass) { |
| 543 |
host = xstrdup(options->hostname); |
544 |
host = xstrdup(options->hostname); |
| 544 |
} else if (options->hostname != NULL) { |
545 |
} else if (options->hostname != NULL) { |
| 545 |
/* NB. Please keep in sync with ssh.c:main() */ |
546 |
/* NB. Please keep in sync with ssh.c:main() */ |
|
Lines 571-578
match_cfg_line(Options *options, char **condition, struct passwd *pw,
Link Here
|
| 571 |
goto out; |
572 |
goto out; |
| 572 |
} |
573 |
} |
| 573 |
attributes++; |
574 |
attributes++; |
| 574 |
if (strcasecmp(attrib, "canonical") == 0) { |
575 |
if (strcasecmp(attrib, "canonical") == 0 || |
| 575 |
r = !!post_canon; /* force bitmask member to boolean */ |
576 |
strcasecmp(attrib, "final") == 0) { |
|
|
577 |
/* |
| 578 |
* If the config requests "Match final" then remember |
| 579 |
* this so we can perform a second pass later. |
| 580 |
*/ |
| 581 |
if (strcasecmp(attrib, "final") == 0 && |
| 582 |
want_final_pass != NULL) |
| 583 |
*want_final_pass = 1; |
| 584 |
r = !!final_pass; /* force bitmask member to boolean */ |
| 576 |
if (r == (negate ? 1 : 0)) |
585 |
if (r == (negate ? 1 : 0)) |
| 577 |
this_result = result = 0; |
586 |
this_result = result = 0; |
| 578 |
debug3("%.200s line %d: %smatched '%s'", |
587 |
debug3("%.200s line %d: %smatched '%s'", |
|
Lines 809-822
process_config_line(Options *options, struct passwd *pw, const char *host,
Link Here
|
| 809 |
int linenum, int *activep, int flags) |
818 |
int linenum, int *activep, int flags) |
| 810 |
{ |
819 |
{ |
| 811 |
return process_config_line_depth(options, pw, host, original_host, |
820 |
return process_config_line_depth(options, pw, host, original_host, |
| 812 |
line, filename, linenum, activep, flags, 0); |
821 |
line, filename, linenum, activep, flags, NULL, 0); |
| 813 |
} |
822 |
} |
| 814 |
|
823 |
|
| 815 |
#define WHITESPACE " \t\r\n" |
824 |
#define WHITESPACE " \t\r\n" |
| 816 |
static int |
825 |
static int |
| 817 |
process_config_line_depth(Options *options, struct passwd *pw, const char *host, |
826 |
process_config_line_depth(Options *options, struct passwd *pw, const char *host, |
| 818 |
const char *original_host, char *line, const char *filename, |
827 |
const char *original_host, char *line, const char *filename, |
| 819 |
int linenum, int *activep, int flags, int depth) |
828 |
int linenum, int *activep, int flags, int *want_final_pass, int depth) |
| 820 |
{ |
829 |
{ |
| 821 |
char *s, **charptr, *endofnumber, *keyword, *arg, *arg2; |
830 |
char *s, **charptr, *endofnumber, *keyword, *arg, *arg2; |
| 822 |
char **cpptr, fwdarg[256]; |
831 |
char **cpptr, fwdarg[256]; |
|
Lines 1315-1321
parse_keytypes:
Link Here
|
| 1315 |
fatal("Host directive not supported as a command-line " |
1324 |
fatal("Host directive not supported as a command-line " |
| 1316 |
"option"); |
1325 |
"option"); |
| 1317 |
value = match_cfg_line(options, &s, pw, host, original_host, |
1326 |
value = match_cfg_line(options, &s, pw, host, original_host, |
| 1318 |
flags & SSHCONF_POSTCANON, filename, linenum); |
1327 |
flags & SSHCONF_FINAL, want_final_pass, |
|
|
1328 |
filename, linenum); |
| 1319 |
if (value < 0) |
1329 |
if (value < 0) |
| 1320 |
fatal("%.200s line %d: Bad Match condition", filename, |
1330 |
fatal("%.200s line %d: Bad Match condition", filename, |
| 1321 |
linenum); |
1331 |
linenum); |
|
Lines 1524-1530
parse_keytypes:
Link Here
|
| 1524 |
pw, host, original_host, options, |
1534 |
pw, host, original_host, options, |
| 1525 |
flags | SSHCONF_CHECKPERM | |
1535 |
flags | SSHCONF_CHECKPERM | |
| 1526 |
(oactive ? 0 : SSHCONF_NEVERMATCH), |
1536 |
(oactive ? 0 : SSHCONF_NEVERMATCH), |
| 1527 |
activep, depth + 1); |
1537 |
activep, want_final_pass, depth + 1); |
| 1528 |
if (r != 1 && errno != ENOENT) { |
1538 |
if (r != 1 && errno != ENOENT) { |
| 1529 |
fatal("Can't open user config file " |
1539 |
fatal("Can't open user config file " |
| 1530 |
"%.100s: %.100s", gl.gl_pathv[i], |
1540 |
"%.100s: %.100s", gl.gl_pathv[i], |
|
Lines 1716-1734
parse_keytypes:
Link Here
|
| 1716 |
*/ |
1726 |
*/ |
| 1717 |
int |
1727 |
int |
| 1718 |
read_config_file(const char *filename, struct passwd *pw, const char *host, |
1728 |
read_config_file(const char *filename, struct passwd *pw, const char *host, |
| 1719 |
const char *original_host, Options *options, int flags) |
1729 |
const char *original_host, Options *options, int flags, |
|
|
1730 |
int *want_final_pass) |
| 1720 |
{ |
1731 |
{ |
| 1721 |
int active = 1; |
1732 |
int active = 1; |
| 1722 |
|
1733 |
|
| 1723 |
return read_config_file_depth(filename, pw, host, original_host, |
1734 |
return read_config_file_depth(filename, pw, host, original_host, |
| 1724 |
options, flags, &active, 0); |
1735 |
options, flags, &active, want_final_pass, 0); |
| 1725 |
} |
1736 |
} |
| 1726 |
|
1737 |
|
| 1727 |
#define READCONF_MAX_DEPTH 16 |
1738 |
#define READCONF_MAX_DEPTH 16 |
| 1728 |
static int |
1739 |
static int |
| 1729 |
read_config_file_depth(const char *filename, struct passwd *pw, |
1740 |
read_config_file_depth(const char *filename, struct passwd *pw, |
| 1730 |
const char *host, const char *original_host, Options *options, |
1741 |
const char *host, const char *original_host, Options *options, |
| 1731 |
int flags, int *activep, int depth) |
1742 |
int flags, int *activep, int *want_final_pass, int depth) |
| 1732 |
{ |
1743 |
{ |
| 1733 |
FILE *f; |
1744 |
FILE *f; |
| 1734 |
char *line = NULL; |
1745 |
char *line = NULL; |
|
Lines 1763-1769
read_config_file_depth(const char *filename, struct passwd *pw,
Link Here
|
| 1763 |
/* Update line number counter. */ |
1774 |
/* Update line number counter. */ |
| 1764 |
linenum++; |
1775 |
linenum++; |
| 1765 |
if (process_config_line_depth(options, pw, host, original_host, |
1776 |
if (process_config_line_depth(options, pw, host, original_host, |
| 1766 |
line, filename, linenum, activep, flags, depth) != 0) |
1777 |
line, filename, linenum, activep, flags, want_final_pass, |
|
|
1778 |
depth) != 0) |
| 1767 |
bad_options++; |
1779 |
bad_options++; |
| 1768 |
} |
1780 |
} |
| 1769 |
free(line); |
1781 |
free(line); |