summaryrefslogtreecommitdiff
path: root/readconf.c
diff options
context:
space:
mode:
Diffstat (limited to 'readconf.c')
-rw-r--r--readconf.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/readconf.c b/readconf.c
index bd13d4176..dad249007 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.210 2013/10/20 06:19:27 djm Exp $ */ 1/* $OpenBSD: readconf.c,v 1.211 2013/10/23 03:03:07 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -457,8 +457,8 @@ static int
457match_cfg_line(Options *options, char **condition, struct passwd *pw, 457match_cfg_line(Options *options, char **condition, struct passwd *pw,
458 const char *host_arg, const char *filename, int linenum) 458 const char *host_arg, const char *filename, int linenum)
459{ 459{
460 char *arg, *attrib, *cmd, *cp = *condition; 460 char *arg, *attrib, *cmd, *cp = *condition, *host;
461 const char *ruser, *host; 461 const char *ruser;
462 int r, port, result = 1; 462 int r, port, result = 1;
463 size_t len; 463 size_t len;
464 char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; 464 char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV];
@@ -469,13 +469,18 @@ match_cfg_line(Options *options, char **condition, struct passwd *pw,
469 */ 469 */
470 port = options->port <= 0 ? default_ssh_port() : options->port; 470 port = options->port <= 0 ? default_ssh_port() : options->port;
471 ruser = options->user == NULL ? pw->pw_name : options->user; 471 ruser = options->user == NULL ? pw->pw_name : options->user;
472 host = options->hostname == NULL ? host_arg : options->hostname; 472 if (options->hostname != NULL) {
473 host = percent_expand(options->hostname,
474 "h", host_arg, (char *)NULL);
475 } else
476 host = xstrdup(host_arg);
473 477
474 debug3("checking match for '%s' host %s", cp, host); 478 debug3("checking match for '%s' host %s", cp, host);
475 while ((attrib = strdelim(&cp)) && *attrib != '\0') { 479 while ((attrib = strdelim(&cp)) && *attrib != '\0') {
476 if ((arg = strdelim(&cp)) == NULL || *arg == '\0') { 480 if ((arg = strdelim(&cp)) == NULL || *arg == '\0') {
477 error("Missing Match criteria for %s", attrib); 481 error("Missing Match criteria for %s", attrib);
478 return -1; 482 result = -1;
483 goto out;
479 } 484 }
480 len = strlen(arg); 485 len = strlen(arg);
481 if (strcasecmp(attrib, "host") == 0) { 486 if (strcasecmp(attrib, "host") == 0) {
@@ -534,11 +539,14 @@ match_cfg_line(Options *options, char **condition, struct passwd *pw,
534 free(cmd); 539 free(cmd);
535 } else { 540 } else {
536 error("Unsupported Match attribute %s", attrib); 541 error("Unsupported Match attribute %s", attrib);
537 return -1; 542 result = -1;
543 goto out;
538 } 544 }
539 } 545 }
540 debug3("match %sfound", result ? "" : "not "); 546 debug3("match %sfound", result ? "" : "not ");
541 *condition = cp; 547 *condition = cp;
548 out:
549 free(host);
542 return result; 550 return result;
543} 551}
544 552