|
Lines 879-884
match_test_missing_fatal(const char *cri
Link Here
|
| 879 |
} |
879 |
} |
| 880 |
|
880 |
|
| 881 |
/* |
881 |
/* |
|
|
882 |
* Return a connection_info structure that can never match, which is used |
| 883 |
* for sshd -T test mode. We can't use NULL since that's already used |
| 884 |
* for "not provided". |
| 885 |
*/ |
| 886 |
static const char *param_nevermatch = "this can never match"; |
| 887 |
struct connection_info * |
| 888 |
nevermatch_connection_info(void) |
| 889 |
{ |
| 890 |
struct connection_info *ci = get_connection_info(0,0); |
| 891 |
|
| 892 |
ci->user = param_nevermatch; |
| 893 |
ci->host = param_nevermatch; |
| 894 |
ci->address = param_nevermatch; |
| 895 |
ci->laddress = param_nevermatch; |
| 896 |
ci->rdomain = param_nevermatch; |
| 897 |
ci->lport = -1; |
| 898 |
return ci; |
| 899 |
} |
| 900 |
|
| 901 |
/* |
| 882 |
* All of the attributes on a single Match line are ANDed together, so we need |
902 |
* All of the attributes on a single Match line are ANDed together, so we need |
| 883 |
* to check every attribute and set the result to zero if any attribute does |
903 |
* to check every attribute and set the result to zero if any attribute does |
| 884 |
* not match. |
904 |
* not match. |
|
Lines 915-921
match_cfg_line(char **condition, int lin
Link Here
|
| 915 |
return -1; |
935 |
return -1; |
| 916 |
} |
936 |
} |
| 917 |
if (strcasecmp(attrib, "user") == 0) { |
937 |
if (strcasecmp(attrib, "user") == 0) { |
| 918 |
if (ci == NULL) { |
938 |
if (ci == NULL || ci->user == param_nevermatch) { |
| 919 |
result = 0; |
939 |
result = 0; |
| 920 |
continue; |
940 |
continue; |
| 921 |
} |
941 |
} |
|
Lines 927-933
match_cfg_line(char **condition, int lin
Link Here
|
| 927 |
debug("user %.100s matched 'User %.100s' at " |
947 |
debug("user %.100s matched 'User %.100s' at " |
| 928 |
"line %d", ci->user, arg, line); |
948 |
"line %d", ci->user, arg, line); |
| 929 |
} else if (strcasecmp(attrib, "group") == 0) { |
949 |
} else if (strcasecmp(attrib, "group") == 0) { |
| 930 |
if (ci == NULL) { |
950 |
if (ci == NULL || ci->user == param_nevermatch) { |
| 931 |
result = 0; |
951 |
result = 0; |
| 932 |
continue; |
952 |
continue; |
| 933 |
} |
953 |
} |
|
Lines 940-946
match_cfg_line(char **condition, int lin
Link Here
|
| 940 |
result = 0; |
960 |
result = 0; |
| 941 |
} |
961 |
} |
| 942 |
} else if (strcasecmp(attrib, "host") == 0) { |
962 |
} else if (strcasecmp(attrib, "host") == 0) { |
| 943 |
if (ci == NULL) { |
963 |
if (ci == NULL || ci->host == param_nevermatch) { |
| 944 |
result = 0; |
964 |
result = 0; |
| 945 |
continue; |
965 |
continue; |
| 946 |
} |
966 |
} |
|
Lines 952-958
match_cfg_line(char **condition, int lin
Link Here
|
| 952 |
debug("connection from %.100s matched 'Host " |
972 |
debug("connection from %.100s matched 'Host " |
| 953 |
"%.100s' at line %d", ci->host, arg, line); |
973 |
"%.100s' at line %d", ci->host, arg, line); |
| 954 |
} else if (strcasecmp(attrib, "address") == 0) { |
974 |
} else if (strcasecmp(attrib, "address") == 0) { |
| 955 |
if (ci == NULL) { |
975 |
if (ci == NULL || ci->address == param_nevermatch) { |
| 956 |
result = 0; |
976 |
result = 0; |
| 957 |
continue; |
977 |
continue; |
| 958 |
} |
978 |
} |
|
Lines 971-977
match_cfg_line(char **condition, int lin
Link Here
|
| 971 |
return -1; |
991 |
return -1; |
| 972 |
} |
992 |
} |
| 973 |
} else if (strcasecmp(attrib, "localaddress") == 0){ |
993 |
} else if (strcasecmp(attrib, "localaddress") == 0){ |
| 974 |
if (ci == NULL) { |
994 |
if (ci == NULL || ci->laddress == param_nevermatch) { |
| 975 |
result = 0; |
995 |
result = 0; |
| 976 |
continue; |
996 |
continue; |
| 977 |
} |
997 |
} |
|
Lines 997-1003
match_cfg_line(char **condition, int lin
Link Here
|
| 997 |
arg); |
1017 |
arg); |
| 998 |
return -1; |
1018 |
return -1; |
| 999 |
} |
1019 |
} |
| 1000 |
if (ci == NULL) { |
1020 |
if (ci == NULL || ci->lport == -1) { |
| 1001 |
result = 0; |
1021 |
result = 0; |
| 1002 |
continue; |
1022 |
continue; |
| 1003 |
} |
1023 |
} |
|
Lines 1011-1020
match_cfg_line(char **condition, int lin
Link Here
|
| 1011 |
else |
1031 |
else |
| 1012 |
result = 0; |
1032 |
result = 0; |
| 1013 |
} else if (strcasecmp(attrib, "rdomain") == 0) { |
1033 |
} else if (strcasecmp(attrib, "rdomain") == 0) { |
| 1014 |
if (ci == NULL || ci->rdomain == NULL) { |
1034 |
if (ci == NULL || ci->rdomain == param_nevermatch) { |
| 1015 |
result = 0; |
1035 |
result = 0; |
| 1016 |
continue; |
1036 |
continue; |
| 1017 |
} |
1037 |
} |
|
|
1038 |
if (ci->rdomain == NULL) |
| 1039 |
match_test_missing_fatal("RDomain", "rdomain"); |
| 1018 |
if (match_pattern_list(ci->rdomain, arg, 0) != 1) |
1040 |
if (match_pattern_list(ci->rdomain, arg, 0) != 1) |
| 1019 |
result = 0; |
1041 |
result = 0; |
| 1020 |
else |
1042 |
else |