7afad6
diff --git a/servconf.c b/servconf.c
7afad6
index ffac5d2c..340045b2 100644
7afad6
--- a/servconf.c
7afad6
+++ b/servconf.c
7afad6
@@ -1042,7 +1042,7 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
7afad6
 			return -1;
7afad6
 		}
7afad6
 		if (strcasecmp(attrib, "user") == 0) {
7afad6
-			if (ci == NULL) {
7afad6
+			if (ci == NULL || (ci->test && ci->user == NULL)) {
7afad6
 				result = 0;
7afad6
 				continue;
7afad6
 			}
7afad6
@@ -1054,7 +1054,7 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
7afad6
 				debug("user %.100s matched 'User %.100s' at "
7afad6
 				    "line %d", ci->user, arg, line);
7afad6
 		} else if (strcasecmp(attrib, "group") == 0) {
7afad6
-			if (ci == NULL) {
7afad6
+			if (ci == NULL || (ci->test && ci->user == NULL)) {
7afad6
 				result = 0;
7afad6
 				continue;
7afad6
 			}
7afad6
@@ -1067,7 +1067,7 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
7afad6
 				result = 0;
7afad6
 			}
7afad6
 		} else if (strcasecmp(attrib, "host") == 0) {
7afad6
-			if (ci == NULL) {
7afad6
+			if (ci == NULL || (ci->test && ci->host == NULL)) {
7afad6
 				result = 0;
7afad6
 				continue;
7afad6
 			}
7afad6
@@ -1079,7 +1079,7 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
7afad6
 				debug("connection from %.100s matched 'Host "
7afad6
 				    "%.100s' at line %d", ci->host, arg, line);
7afad6
 		} else if (strcasecmp(attrib, "address") == 0) {
7afad6
-			if (ci == NULL) {
7afad6
+			if (ci == NULL || (ci->test && ci->address == NULL)) {
7afad6
 				result = 0;
7afad6
 				continue;
7afad6
 			}
7afad6
@@ -1098,7 +1098,7 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
7afad6
 				return -1;
7afad6
 			}
7afad6
 		} else if (strcasecmp(attrib, "localaddress") == 0){
7afad6
-			if (ci == NULL) {
7afad6
+			if (ci == NULL || (ci->test && ci->laddress == NULL)) {
7afad6
 				result = 0;
7afad6
 				continue;
7afad6
 			}
7afad6
@@ -1124,7 +1124,7 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
7afad6
 				    arg);
7afad6
 				return -1;
7afad6
 			}
7afad6
-			if (ci == NULL) {
7afad6
+			if (ci == NULL || (ci->test && ci->lport == -1)) {
7afad6
 				result = 0;
7afad6
 				continue;
7afad6
 			}
7afad6
@@ -1138,10 +1138,12 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
7afad6
 			else
7afad6
 				result = 0;
7afad6
 		} else if (strcasecmp(attrib, "rdomain") == 0) {
7afad6
-			if (ci == NULL || ci->rdomain == NULL) {
7afad6
+			if (ci == NULL || (ci->test && ci->rdomain == NULL)) {
7afad6
 				result = 0;
7afad6
 				continue;
7afad6
 			}
7afad6
+			if (ci->rdomain == NULL)
7afad6
+				match_test_missing_fatal("RDomain", "rdomain");
7afad6
 			if (match_pattern_list(ci->rdomain, arg, 0) != 1)
7afad6
 				result = 0;
7afad6
 			else
7afad6
diff --git a/servconf.h b/servconf.h
7afad6
index 54e0a8d8..5483da05 100644
7afad6
--- a/servconf.h
7afad6
+++ b/servconf.h
7afad6
@@ -221,6 +221,8 @@ struct connection_info {
7afad6
 	const char *laddress;	/* local address */
7afad6
 	int lport;		/* local port */
7afad6
 	const char *rdomain;	/* routing domain if available */
7afad6
+	int test;		/* test mode, allow some attributes to be
7afad6
+				 * unspecified */
7afad6
 };
7afad6
 
7afad6
 
7afad6
diff --git a/sshd.c b/sshd.c
7afad6
index cbd3bce9..1fcde502 100644
7afad6
--- a/sshd.c
7afad6
+++ b/sshd.c
7afad6
@@ -1843,6 +1843,7 @@ main(int ac, char **av)
7afad6
 		 */
7afad6
 		if (connection_info == NULL)
7afad6
 			connection_info = get_connection_info(ssh, 0, 0);
7afad6
+		connection_info->test = 1;
7afad6
 		parse_server_match_config(&options, connection_info);
7afad6
 		dump_config(&options);
7afad6
 	}