rcolebaugh / rpms / openssh

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