version 1.301, 2018/11/16 03:26:01 |
version 1.302, 2018/11/23 05:08:07 |
|
|
|
|
static int read_config_file_depth(const char *filename, struct passwd *pw, |
static int read_config_file_depth(const char *filename, struct passwd *pw, |
const char *host, const char *original_host, Options *options, |
const char *host, const char *original_host, Options *options, |
int flags, int *activep, int depth); |
int flags, int *activep, int *want_final_pass, int depth); |
static int process_config_line_depth(Options *options, struct passwd *pw, |
static int process_config_line_depth(Options *options, struct passwd *pw, |
const char *host, const char *original_host, char *line, |
const char *host, const char *original_host, char *line, |
const char *filename, int linenum, int *activep, int flags, int depth); |
const char *filename, int linenum, int *activep, int flags, |
|
int *want_final_pass, int depth); |
|
|
/* Keyword tokens. */ |
/* Keyword tokens. */ |
|
|
|
|
*/ |
*/ |
static int |
static int |
match_cfg_line(Options *options, char **condition, struct passwd *pw, |
match_cfg_line(Options *options, char **condition, struct passwd *pw, |
const char *host_arg, const char *original_host, int post_canon, |
const char *host_arg, const char *original_host, int final_pass, |
const char *filename, int linenum) |
int *want_final_pass, const char *filename, int linenum) |
{ |
{ |
char *arg, *oattrib, *attrib, *cmd, *cp = *condition, *host, *criteria; |
char *arg, *oattrib, *attrib, *cmd, *cp = *condition, *host, *criteria; |
const char *ruser; |
const char *ruser; |
|
|
*/ |
*/ |
port = options->port <= 0 ? default_ssh_port() : options->port; |
port = options->port <= 0 ? default_ssh_port() : options->port; |
ruser = options->user == NULL ? pw->pw_name : options->user; |
ruser = options->user == NULL ? pw->pw_name : options->user; |
if (post_canon) { |
if (final_pass) { |
host = xstrdup(options->hostname); |
host = xstrdup(options->hostname); |
} else if (options->hostname != NULL) { |
} else if (options->hostname != NULL) { |
/* NB. Please keep in sync with ssh.c:main() */ |
/* NB. Please keep in sync with ssh.c:main() */ |
|
|
goto out; |
goto out; |
} |
} |
attributes++; |
attributes++; |
if (strcasecmp(attrib, "canonical") == 0) { |
if (strcasecmp(attrib, "canonical") == 0 || |
r = !!post_canon; /* force bitmask member to boolean */ |
strcasecmp(attrib, "final") == 0) { |
|
/* |
|
* If the config requests "Match final" then remember |
|
* this so we can perform a second pass later. |
|
*/ |
|
if (strcasecmp(attrib, "final") == 0 && |
|
want_final_pass != NULL) |
|
*want_final_pass = 1; |
|
r = !!final_pass; /* force bitmask member to boolean */ |
if (r == (negate ? 1 : 0)) |
if (r == (negate ? 1 : 0)) |
this_result = result = 0; |
this_result = result = 0; |
debug3("%.200s line %d: %smatched '%s'", |
debug3("%.200s line %d: %smatched '%s'", |
|
|
int linenum, int *activep, int flags) |
int linenum, int *activep, int flags) |
{ |
{ |
return process_config_line_depth(options, pw, host, original_host, |
return process_config_line_depth(options, pw, host, original_host, |
line, filename, linenum, activep, flags, 0); |
line, filename, linenum, activep, flags, NULL, 0); |
} |
} |
|
|
#define WHITESPACE " \t\r\n" |
#define WHITESPACE " \t\r\n" |
static int |
static int |
process_config_line_depth(Options *options, struct passwd *pw, const char *host, |
process_config_line_depth(Options *options, struct passwd *pw, const char *host, |
const char *original_host, char *line, const char *filename, |
const char *original_host, char *line, const char *filename, |
int linenum, int *activep, int flags, int depth) |
int linenum, int *activep, int flags, int *want_final_pass, int depth) |
{ |
{ |
char *s, **charptr, *endofnumber, *keyword, *arg, *arg2; |
char *s, **charptr, *endofnumber, *keyword, *arg, *arg2; |
char **cpptr, fwdarg[256]; |
char **cpptr, fwdarg[256]; |
|
|
fatal("Host directive not supported as a command-line " |
fatal("Host directive not supported as a command-line " |
"option"); |
"option"); |
value = match_cfg_line(options, &s, pw, host, original_host, |
value = match_cfg_line(options, &s, pw, host, original_host, |
flags & SSHCONF_POSTCANON, filename, linenum); |
flags & SSHCONF_FINAL, want_final_pass, |
|
filename, linenum); |
if (value < 0) |
if (value < 0) |
fatal("%.200s line %d: Bad Match condition", filename, |
fatal("%.200s line %d: Bad Match condition", filename, |
linenum); |
linenum); |
|
|
pw, host, original_host, options, |
pw, host, original_host, options, |
flags | SSHCONF_CHECKPERM | |
flags | SSHCONF_CHECKPERM | |
(oactive ? 0 : SSHCONF_NEVERMATCH), |
(oactive ? 0 : SSHCONF_NEVERMATCH), |
activep, depth + 1); |
activep, want_final_pass, depth + 1); |
if (r != 1 && errno != ENOENT) { |
if (r != 1 && errno != ENOENT) { |
fatal("Can't open user config file " |
fatal("Can't open user config file " |
"%.100s: %.100s", gl.gl_pathv[i], |
"%.100s: %.100s", gl.gl_pathv[i], |
|
|
*/ |
*/ |
int |
int |
read_config_file(const char *filename, struct passwd *pw, const char *host, |
read_config_file(const char *filename, struct passwd *pw, const char *host, |
const char *original_host, Options *options, int flags) |
const char *original_host, Options *options, int flags, |
|
int *want_final_pass) |
{ |
{ |
int active = 1; |
int active = 1; |
|
|
return read_config_file_depth(filename, pw, host, original_host, |
return read_config_file_depth(filename, pw, host, original_host, |
options, flags, &active, 0); |
options, flags, &active, want_final_pass, 0); |
} |
} |
|
|
#define READCONF_MAX_DEPTH 16 |
#define READCONF_MAX_DEPTH 16 |
static int |
static int |
read_config_file_depth(const char *filename, struct passwd *pw, |
read_config_file_depth(const char *filename, struct passwd *pw, |
const char *host, const char *original_host, Options *options, |
const char *host, const char *original_host, Options *options, |
int flags, int *activep, int depth) |
int flags, int *activep, int *want_final_pass, int depth) |
{ |
{ |
FILE *f; |
FILE *f; |
char *line = NULL; |
char *line = NULL; |
|
|
/* Update line number counter. */ |
/* Update line number counter. */ |
linenum++; |
linenum++; |
if (process_config_line_depth(options, pw, host, original_host, |
if (process_config_line_depth(options, pw, host, original_host, |
line, filename, linenum, activep, flags, depth) != 0) |
line, filename, linenum, activep, flags, want_final_pass, |
|
depth) != 0) |
bad_options++; |
bad_options++; |
} |
} |
free(line); |
free(line); |