]> andersk Git - gssapi-openssh.git/blame - openssh/compat.c
check for existence of globus_gss_assist_map_and_authorize()
[gssapi-openssh.git] / openssh / compat.c
CommitLineData
3c0ef626 1/*
1e608e42 2 * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved.
3c0ef626 3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#include "includes.h"
dfddba3d 26RCSID("$OpenBSD: compat.c,v 1.71 2005/03/01 10:09:52 djm Exp $");
3c0ef626 27
1e608e42 28#include "buffer.h"
3c0ef626 29#include "packet.h"
30#include "xmalloc.h"
31#include "compat.h"
32#include "log.h"
1e608e42 33#include "match.h"
3c0ef626 34
35int compat13 = 0;
36int compat20 = 0;
37int datafellows = 0;
38
39void
40enable_compat20(void)
41{
d03f4262 42 debug("Enabling compatibility mode for protocol 2.0");
3c0ef626 43 compat20 = 1;
44}
45void
46enable_compat13(void)
47{
d03f4262 48 debug("Enabling compatibility mode for protocol 1.3");
3c0ef626 49 compat13 = 1;
50}
51/* datafellows bug compatibility */
52void
53compat_datafellows(const char *version)
54{
1e608e42 55 int i;
3c0ef626 56 static struct {
57 char *pat;
58 int bugs;
59 } check[] = {
1e608e42 60 { "OpenSSH-2.0*,"
61 "OpenSSH-2.1*,"
62 "OpenSSH_2.1*,"
63 "OpenSSH_2.2*", SSH_OLD_SESSIONID|SSH_BUG_BANNER|
510132b6 64 SSH_OLD_DHGEX|SSH_BUG_NOREKEY|
dfddba3d 65 SSH_BUG_EXTEOF|SSH_OLD_FORWARD_ADDR},
1e608e42 66 { "OpenSSH_2.3.0*", SSH_BUG_BANNER|SSH_BUG_BIGENDIANAES|
510132b6 67 SSH_OLD_DHGEX|SSH_BUG_NOREKEY|
dfddba3d 68 SSH_BUG_EXTEOF|SSH_OLD_FORWARD_ADDR},
1e608e42 69 { "OpenSSH_2.3.*", SSH_BUG_BIGENDIANAES|SSH_OLD_DHGEX|
dfddba3d 70 SSH_BUG_NOREKEY|SSH_BUG_EXTEOF|
71 SSH_OLD_FORWARD_ADDR},
1e608e42 72 { "OpenSSH_2.5.0p1*,"
73 "OpenSSH_2.5.1p1*",
3c0ef626 74 SSH_BUG_BIGENDIANAES|SSH_OLD_DHGEX|
510132b6 75 SSH_BUG_NOREKEY|SSH_BUG_EXTEOF|
dfddba3d 76 SSH_OLD_FORWARD_ADDR},
1e608e42 77 { "OpenSSH_2.5.0*,"
78 "OpenSSH_2.5.1*,"
510132b6 79 "OpenSSH_2.5.2*", SSH_OLD_DHGEX|SSH_BUG_NOREKEY|
dfddba3d 80 SSH_BUG_EXTEOF|SSH_OLD_FORWARD_ADDR},
81 { "OpenSSH_2.5.3*", SSH_BUG_NOREKEY|SSH_BUG_EXTEOF|
82 SSH_OLD_FORWARD_ADDR},
510132b6 83 { "OpenSSH_2.*,"
84 "OpenSSH_3.0*,"
dfddba3d 85 "OpenSSH_3.1*", SSH_BUG_EXTEOF|SSH_OLD_FORWARD_ADDR},
86 { "OpenSSH_3.*", SSH_OLD_FORWARD_ADDR },
510132b6 87 { "Sun_SSH_1.0*", SSH_BUG_NOREKEY|SSH_BUG_EXTEOF},
1e608e42 88 { "OpenSSH*", 0 },
89 { "*MindTerm*", 0 },
90 { "2.1.0*", SSH_BUG_SIGBLOB|SSH_BUG_HMAC|
3c0ef626 91 SSH_OLD_SESSIONID|SSH_BUG_DEBUG|
bfe49944 92 SSH_BUG_RSASIGMD5|SSH_BUG_HBSERVICE|
93 SSH_BUG_FIRSTKEX },
1e608e42 94 { "2.1 *", SSH_BUG_SIGBLOB|SSH_BUG_HMAC|
3c0ef626 95 SSH_OLD_SESSIONID|SSH_BUG_DEBUG|
bfe49944 96 SSH_BUG_RSASIGMD5|SSH_BUG_HBSERVICE|
97 SSH_BUG_FIRSTKEX },
1e608e42 98 { "2.0.13*,"
99 "2.0.14*,"
100 "2.0.15*,"
101 "2.0.16*,"
102 "2.0.17*,"
103 "2.0.18*,"
104 "2.0.19*", SSH_BUG_SIGBLOB|SSH_BUG_HMAC|
3c0ef626 105 SSH_OLD_SESSIONID|SSH_BUG_DEBUG|
106 SSH_BUG_PKSERVICE|SSH_BUG_X11FWD|
107 SSH_BUG_PKOK|SSH_BUG_RSASIGMD5|
108 SSH_BUG_HBSERVICE|SSH_BUG_OPENFAILURE|
bfe49944 109 SSH_BUG_DUMMYCHAN|SSH_BUG_FIRSTKEX },
1e608e42 110 { "2.0.11*,"
111 "2.0.12*", SSH_BUG_SIGBLOB|SSH_BUG_HMAC|
3c0ef626 112 SSH_OLD_SESSIONID|SSH_BUG_DEBUG|
113 SSH_BUG_PKSERVICE|SSH_BUG_X11FWD|
114 SSH_BUG_PKAUTH|SSH_BUG_PKOK|
115 SSH_BUG_RSASIGMD5|SSH_BUG_OPENFAILURE|
bfe49944 116 SSH_BUG_DUMMYCHAN|SSH_BUG_FIRSTKEX },
1e608e42 117 { "2.0.*", SSH_BUG_SIGBLOB|SSH_BUG_HMAC|
3c0ef626 118 SSH_OLD_SESSIONID|SSH_BUG_DEBUG|
119 SSH_BUG_PKSERVICE|SSH_BUG_X11FWD|
120 SSH_BUG_PKAUTH|SSH_BUG_PKOK|
121 SSH_BUG_RSASIGMD5|SSH_BUG_OPENFAILURE|
bfe49944 122 SSH_BUG_DERIVEKEY|SSH_BUG_DUMMYCHAN|
123 SSH_BUG_FIRSTKEX },
1e608e42 124 { "2.2.0*,"
125 "2.3.0*", SSH_BUG_HMAC|SSH_BUG_DEBUG|
bfe49944 126 SSH_BUG_RSASIGMD5|SSH_BUG_FIRSTKEX },
127 { "2.3.*", SSH_BUG_DEBUG|SSH_BUG_RSASIGMD5|
128 SSH_BUG_FIRSTKEX },
1e608e42 129 { "2.4", SSH_OLD_SESSIONID }, /* Van Dyke */
bfe49944 130 { "2.*", SSH_BUG_DEBUG|SSH_BUG_FIRSTKEX },
1e608e42 131 { "3.0.*", SSH_BUG_DEBUG },
132 { "3.0 SecureCRT*", SSH_OLD_SESSIONID },
133 { "1.7 SecureFX*", SSH_OLD_SESSIONID },
134 { "1.2.18*,"
135 "1.2.19*,"
136 "1.2.20*,"
137 "1.2.21*,"
7cac2b65 138 "1.2.22*", SSH_BUG_IGNOREMSG },
510132b6 139 { "1.3.2*", /* F-Secure */
7cac2b65 140 SSH_BUG_IGNOREMSG },
1e608e42 141 { "*SSH Compatible Server*", /* Netscreen */
3c0ef626 142 SSH_BUG_PASSWORDPAD },
1e608e42 143 { "*OSU_0*,"
144 "OSU_1.0*,"
145 "OSU_1.1*,"
146 "OSU_1.2*,"
147 "OSU_1.3*,"
148 "OSU_1.4*,"
149 "OSU_1.5alpha1*,"
150 "OSU_1.5alpha2*,"
151 "OSU_1.5alpha3*", SSH_BUG_PASSWORDPAD },
152 { "*SSH_Version_Mapper*",
3c0ef626 153 SSH_BUG_SCANNER },
d03f4262 154 { "Probe-*",
155 SSH_BUG_PROBE },
3c0ef626 156 { NULL, 0 }
157 };
1e608e42 158
3c0ef626 159 /* process table, return first match */
160 for (i = 0; check[i].pat; i++) {
1e608e42 161 if (match_pattern_list(version, check[i].pat,
162 strlen(check[i].pat), 0) == 1) {
3c0ef626 163 debug("match: %s pat %s", version, check[i].pat);
164 datafellows = check[i].bugs;
473db5ab 165 /* Check to see if the remote side is OpenSSH and not HPN */
166 if(strstr(version,"OpenSSH") != NULL)
167 {
168 if (strstr(version,"hpn") == NULL)
169 {
170 datafellows |= SSH_BUG_LARGEWINDOW;
171 }
172 }
3c0ef626 173 return;
174 }
175 }
176 debug("no match: %s", version);
177}
178
179#define SEP ","
180int
181proto_spec(const char *spec)
182{
183 char *s, *p, *q;
184 int ret = SSH_PROTO_UNKNOWN;
185
186 if (spec == NULL)
187 return ret;
188 q = s = xstrdup(spec);
189 for ((p = strsep(&q, SEP)); p && *p != '\0'; (p = strsep(&q, SEP))) {
1e608e42 190 switch (atoi(p)) {
3c0ef626 191 case 1:
192 if (ret == SSH_PROTO_UNKNOWN)
193 ret |= SSH_PROTO_1_PREFERRED;
194 ret |= SSH_PROTO_1;
195 break;
196 case 2:
197 ret |= SSH_PROTO_2;
198 break;
199 default:
7cac2b65 200 logit("ignoring bad proto spec: '%s'.", p);
3c0ef626 201 break;
202 }
203 }
204 xfree(s);
205 return ret;
206}
207
208char *
209compat_cipher_proposal(char *cipher_prop)
210{
1e608e42 211 Buffer b;
3c0ef626 212 char *orig_prop, *fix_ciphers;
213 char *cp, *tmp;
3c0ef626 214
215 if (!(datafellows & SSH_BUG_BIGENDIANAES))
216 return(cipher_prop);
217
1e608e42 218 buffer_init(&b);
3c0ef626 219 tmp = orig_prop = xstrdup(cipher_prop);
1e608e42 220 while ((cp = strsep(&tmp, ",")) != NULL) {
221 if (strncmp(cp, "aes", 3) != 0) {
222 if (buffer_len(&b) > 0)
223 buffer_append(&b, ",", 1);
224 buffer_append(&b, cp, strlen(cp));
3c0ef626 225 }
226 }
1e608e42 227 buffer_append(&b, "\0", 1);
228 fix_ciphers = xstrdup(buffer_ptr(&b));
229 buffer_free(&b);
3c0ef626 230 xfree(orig_prop);
231 debug2("Original cipher proposal: %s", cipher_prop);
232 debug2("Compat cipher proposal: %s", fix_ciphers);
233 if (!*fix_ciphers)
234 fatal("No available ciphers found.");
235
236 return(fix_ciphers);
237}
This page took 0.106219 seconds and 5 git commands to generate.