]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: When running sshd -T, assume any attibute not provided by
authordtucker@openbsd.org <dtucker@openbsd.org>
Thu, 18 Apr 2019 18:56:16 +0000 (18:56 +0000)
committerDamien Miller <djm@mindrot.org>
Wed, 8 May 2019 08:42:03 +0000 (18:42 +1000)
-C does not match, which allows it to work when sshd_config contains a Match
directive with or without -C.  bz#2858, ok djm@

OpenBSD-Commit-ID: 1a701f0a33e3bc96753cfda2fe0b0378520b82eb

servconf.c
servconf.h
sshd.c

index ffac5d2c7e0bf38bf0c46501519a073d2d809f7c..340045b281221a25094e65826cfaa49f3d211f95 100644 (file)
@@ -1,5 +1,5 @@
 
-/* $OpenBSD: servconf.c,v 1.350 2019/03/25 22:33:44 djm Exp $ */
+/* $OpenBSD: servconf.c,v 1.351 2019/04/18 18:56:16 dtucker Exp $ */
 /*
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
  *                    All rights reserved
@@ -1042,7 +1042,7 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
                        return -1;
                }
                if (strcasecmp(attrib, "user") == 0) {
-                       if (ci == NULL) {
+                       if (ci == NULL || (ci->test && ci->user == NULL)) {
                                result = 0;
                                continue;
                        }
@@ -1054,7 +1054,7 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
                                debug("user %.100s matched 'User %.100s' at "
                                    "line %d", ci->user, arg, line);
                } else if (strcasecmp(attrib, "group") == 0) {
-                       if (ci == NULL) {
+                       if (ci == NULL || (ci->test && ci->user == NULL)) {
                                result = 0;
                                continue;
                        }
@@ -1067,7 +1067,7 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
                                result = 0;
                        }
                } else if (strcasecmp(attrib, "host") == 0) {
-                       if (ci == NULL) {
+                       if (ci == NULL || (ci->test && ci->host == NULL)) {
                                result = 0;
                                continue;
                        }
@@ -1079,7 +1079,7 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
                                debug("connection from %.100s matched 'Host "
                                    "%.100s' at line %d", ci->host, arg, line);
                } else if (strcasecmp(attrib, "address") == 0) {
-                       if (ci == NULL) {
+                       if (ci == NULL || (ci->test && ci->address == NULL)) {
                                result = 0;
                                continue;
                        }
@@ -1098,7 +1098,7 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
                                return -1;
                        }
                } else if (strcasecmp(attrib, "localaddress") == 0){
-                       if (ci == NULL) {
+                       if (ci == NULL || (ci->test && ci->laddress == NULL)) {
                                result = 0;
                                continue;
                        }
@@ -1124,7 +1124,7 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
                                    arg);
                                return -1;
                        }
-                       if (ci == NULL) {
+                       if (ci == NULL || (ci->test && ci->lport == -1)) {
                                result = 0;
                                continue;
                        }
@@ -1138,10 +1138,12 @@ match_cfg_line(char **condition, int line, struct connection_info *ci)
                        else
                                result = 0;
                } else if (strcasecmp(attrib, "rdomain") == 0) {
-                       if (ci == NULL || ci->rdomain == NULL) {
+                       if (ci == NULL || (ci->test && ci->rdomain == NULL)) {
                                result = 0;
                                continue;
                        }
+                       if (ci->rdomain == NULL)
+                               match_test_missing_fatal("RDomain", "rdomain");
                        if (match_pattern_list(ci->rdomain, arg, 0) != 1)
                                result = 0;
                        else
index 54e0a8d8d9b95721f0be9780db4e60920c8a27fe..5483da0511d84bad11046678c62cc85e42cc8081 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: servconf.h,v 1.139 2019/01/19 21:37:48 djm Exp $ */
+/* $OpenBSD: servconf.h,v 1.140 2019/04/18 18:56:16 dtucker Exp $ */
 
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -221,6 +221,8 @@ struct connection_info {
        const char *laddress;   /* local address */
        int lport;              /* local port */
        const char *rdomain;    /* routing domain if available */
+       int test;               /* test mode, allow some attributes to be
+                                * unspecified */
 };
 
 
diff --git a/sshd.c b/sshd.c
index cbd3bce913ec74051c4f342e341a4ccad459f277..1fcde502b25aa87176e96641d0ba7e8d81f9c10a 100644 (file)
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshd.c,v 1.533 2019/03/01 02:32:39 djm Exp $ */
+/* $OpenBSD: sshd.c,v 1.534 2019/04/18 18:56:16 dtucker Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1843,6 +1843,7 @@ main(int ac, char **av)
                 */
                if (connection_info == NULL)
                        connection_info = get_connection_info(ssh, 0, 0);
+               connection_info->test = 1;
                parse_server_match_config(&options, connection_info);
                dump_config(&options);
        }