version 1.210, 2013/10/20 06:19:27 |
version 1.211, 2013/10/23 03:03:07 |
|
|
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 *filename, int linenum) |
const char *host_arg, const char *filename, int linenum) |
{ |
{ |
char *arg, *attrib, *cmd, *cp = *condition; |
char *arg, *attrib, *cmd, *cp = *condition, *host; |
const char *ruser, *host; |
const char *ruser; |
int r, port, result = 1; |
int r, port, result = 1; |
size_t len; |
size_t len; |
char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; |
char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; |
|
|
*/ |
*/ |
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; |
host = options->hostname == NULL ? host_arg : options->hostname; |
if (options->hostname != NULL) { |
|
host = percent_expand(options->hostname, |
|
"h", host_arg, (char *)NULL); |
|
} else |
|
host = xstrdup(host_arg); |
|
|
debug3("checking match for '%s' host %s", cp, host); |
debug3("checking match for '%s' host %s", cp, host); |
while ((attrib = strdelim(&cp)) && *attrib != '\0') { |
while ((attrib = strdelim(&cp)) && *attrib != '\0') { |
if ((arg = strdelim(&cp)) == NULL || *arg == '\0') { |
if ((arg = strdelim(&cp)) == NULL || *arg == '\0') { |
error("Missing Match criteria for %s", attrib); |
error("Missing Match criteria for %s", attrib); |
return -1; |
result = -1; |
|
goto out; |
} |
} |
len = strlen(arg); |
len = strlen(arg); |
if (strcasecmp(attrib, "host") == 0) { |
if (strcasecmp(attrib, "host") == 0) { |
|
|
free(cmd); |
free(cmd); |
} else { |
} else { |
error("Unsupported Match attribute %s", attrib); |
error("Unsupported Match attribute %s", attrib); |
return -1; |
result = -1; |
|
goto out; |
} |
} |
} |
} |
debug3("match %sfound", result ? "" : "not "); |
debug3("match %sfound", result ? "" : "not "); |
*condition = cp; |
*condition = cp; |
|
out: |
|
free(host); |
return result; |
return result; |
} |
} |
|
|