46ed7b64 |
1 | /* |
2 | * Platform-independent bits of X11 forwarding. |
3 | */ |
4 | |
9c964e85 |
5 | #include <stdio.h> |
6 | #include <stdlib.h> |
e0e7dff8 |
7 | #include <assert.h> |
2f92b717 |
8 | #include <time.h> |
9c964e85 |
9 | |
10 | #include "putty.h" |
11 | #include "ssh.h" |
12 | |
9c964e85 |
13 | #define GET_32BIT_LSB_FIRST(cp) \ |
14 | (((unsigned long)(unsigned char)(cp)[0]) | \ |
15 | ((unsigned long)(unsigned char)(cp)[1] << 8) | \ |
16 | ((unsigned long)(unsigned char)(cp)[2] << 16) | \ |
17 | ((unsigned long)(unsigned char)(cp)[3] << 24)) |
18 | |
19 | #define PUT_32BIT_LSB_FIRST(cp, value) ( \ |
b3ebaa28 |
20 | (cp)[0] = (char)(value), \ |
21 | (cp)[1] = (char)((value) >> 8), \ |
22 | (cp)[2] = (char)((value) >> 16), \ |
23 | (cp)[3] = (char)((value) >> 24) ) |
9c964e85 |
24 | |
25 | #define GET_16BIT_LSB_FIRST(cp) \ |
26 | (((unsigned long)(unsigned char)(cp)[0]) | \ |
27 | ((unsigned long)(unsigned char)(cp)[1] << 8)) |
28 | |
29 | #define PUT_16BIT_LSB_FIRST(cp, value) ( \ |
b3ebaa28 |
30 | (cp)[0] = (char)(value), \ |
31 | (cp)[1] = (char)((value) >> 8) ) |
9c964e85 |
32 | |
33 | #define GET_32BIT_MSB_FIRST(cp) \ |
34 | (((unsigned long)(unsigned char)(cp)[0] << 24) | \ |
35 | ((unsigned long)(unsigned char)(cp)[1] << 16) | \ |
36 | ((unsigned long)(unsigned char)(cp)[2] << 8) | \ |
37 | ((unsigned long)(unsigned char)(cp)[3])) |
38 | |
39 | #define PUT_32BIT_MSB_FIRST(cp, value) ( \ |
b3ebaa28 |
40 | (cp)[0] = (char)((value) >> 24), \ |
41 | (cp)[1] = (char)((value) >> 16), \ |
42 | (cp)[2] = (char)((value) >> 8), \ |
43 | (cp)[3] = (char)(value) ) |
9c964e85 |
44 | |
45 | #define GET_16BIT_MSB_FIRST(cp) \ |
46 | (((unsigned long)(unsigned char)(cp)[0] << 8) | \ |
47 | ((unsigned long)(unsigned char)(cp)[1])) |
48 | |
49 | #define PUT_16BIT_MSB_FIRST(cp, value) ( \ |
b3ebaa28 |
50 | (cp)[0] = (char)((value) >> 8), \ |
51 | (cp)[1] = (char)(value) ) |
9c964e85 |
52 | |
53 | #define GET_16BIT(endian, cp) \ |
54 | (endian=='B' ? GET_16BIT_MSB_FIRST(cp) : GET_16BIT_LSB_FIRST(cp)) |
55 | |
56 | #define PUT_16BIT(endian, cp, val) \ |
57 | (endian=='B' ? PUT_16BIT_MSB_FIRST(cp, val) : PUT_16BIT_LSB_FIRST(cp, val)) |
58 | |
e0e7dff8 |
59 | const char *const x11_authnames[] = { |
2f92b717 |
60 | "", "MIT-MAGIC-COOKIE-1", "XDM-AUTHORIZATION-1" |
e0e7dff8 |
61 | }; |
62 | |
302121de |
63 | struct X11Auth { |
e0e7dff8 |
64 | unsigned char fakedata[64], realdata[64]; |
65 | int fakeproto, realproto; |
66 | int fakelen, reallen; |
302121de |
67 | }; |
68 | |
9c964e85 |
69 | struct X11Private { |
302121de |
70 | const struct plug_function_table *fn; |
7e78000d |
71 | /* the above variable absolutely *must* be the first in this structure */ |
32874aea |
72 | unsigned char firstpkt[12]; /* first X data packet */ |
302121de |
73 | struct X11Auth *auth; |
9c964e85 |
74 | char *auth_protocol; |
75 | unsigned char *auth_data; |
76 | int data_read, auth_plen, auth_psize, auth_dlen, auth_dsize; |
77 | int verified; |
5471d09a |
78 | int throttled, throttle_override; |
b3ebaa28 |
79 | unsigned long peer_ip; |
80 | int peer_port; |
32874aea |
81 | void *c; /* data used by ssh.c */ |
7e78000d |
82 | Socket s; |
9c964e85 |
83 | }; |
84 | |
302121de |
85 | void *x11_invent_auth(char *proto, int protomaxlen, |
b3ebaa28 |
86 | char *data, int datamaxlen, int proto_id) |
32874aea |
87 | { |
3d88e64d |
88 | struct X11Auth *auth = snew(struct X11Auth); |
9c964e85 |
89 | char ourdata[64]; |
90 | int i; |
91 | |
b3ebaa28 |
92 | if (proto_id == X11_MIT) { |
93 | auth->fakeproto = X11_MIT; |
e0e7dff8 |
94 | |
b3ebaa28 |
95 | /* MIT-MAGIC-COOKIE-1. Cookie size is 128 bits (16 bytes). */ |
96 | auth->fakelen = 16; |
97 | for (i = 0; i < 16; i++) |
98 | auth->fakedata[i] = random_byte(); |
99 | } else { |
100 | assert(proto_id == X11_XDM); |
101 | auth->fakeproto = X11_XDM; |
102 | |
103 | /* XDM-AUTHORIZATION-1. Cookie size is 16 bytes; byte 8 is zero. */ |
104 | auth->fakelen = 16; |
105 | for (i = 0; i < 16; i++) |
106 | auth->fakedata[i] = (i == 8 ? 0 : random_byte()); |
107 | } |
9c964e85 |
108 | |
109 | /* Now format for the recipient. */ |
e0e7dff8 |
110 | strncpy(proto, x11_authnames[auth->fakeproto], protomaxlen); |
9c964e85 |
111 | ourdata[0] = '\0'; |
e0e7dff8 |
112 | for (i = 0; i < auth->fakelen; i++) |
113 | sprintf(ourdata + strlen(ourdata), "%02x", auth->fakedata[i]); |
9c964e85 |
114 | strncpy(data, ourdata, datamaxlen); |
302121de |
115 | |
116 | return auth; |
9c964e85 |
117 | } |
118 | |
fabd1805 |
119 | void x11_free_auth(void *auth) |
120 | { |
121 | |
122 | sfree(auth); |
123 | } |
124 | |
e0e7dff8 |
125 | /* |
126 | * Fetch the real auth data for a given display string, and store |
127 | * it in an X11Auth structure. Returns NULL on success, or an error |
128 | * string. |
129 | */ |
130 | void x11_get_real_auth(void *authv, char *display) |
131 | { |
132 | struct X11Auth *auth = (struct X11Auth *)authv; |
133 | |
134 | auth->realproto = X11_NO_AUTH; /* in case next call does nothing */ |
135 | |
136 | auth->reallen = sizeof(auth->realdata); |
137 | platform_get_x11_auth(display, &auth->realproto, |
138 | auth->realdata, &auth->reallen); |
139 | } |
140 | |
b3ebaa28 |
141 | static char *x11_verify(unsigned long peer_ip, int peer_port, |
142 | struct X11Auth *auth, char *proto, |
143 | unsigned char *data, int dlen) |
32874aea |
144 | { |
e0e7dff8 |
145 | if (strcmp(proto, x11_authnames[auth->fakeproto]) != 0) |
b3ebaa28 |
146 | return "wrong authentication protocol attempted"; |
e0e7dff8 |
147 | if (auth->fakeproto == X11_MIT) { |
148 | if (dlen != auth->fakelen) |
b3ebaa28 |
149 | return "MIT-MAGIC-COOKIE-1 data was wrong length"; |
e0e7dff8 |
150 | if (memcmp(auth->fakedata, data, dlen) != 0) |
b3ebaa28 |
151 | return "MIT-MAGIC-COOKIE-1 data did not match"; |
152 | } |
153 | if (auth->fakeproto == X11_XDM) { |
154 | unsigned long t; |
155 | time_t tim; |
156 | int i; |
157 | |
158 | if (dlen != 24) |
159 | return "XDM-AUTHORIZATION-1 data was wrong length"; |
160 | if (peer_port == -1) |
161 | return "cannot do XDM-AUTHORIZATION-1 without remote address data"; |
162 | des_decrypt_xdmauth(auth->fakedata+9, data, 24); |
163 | if (memcmp(auth->fakedata, data, 8) != 0) |
164 | return "XDM-AUTHORIZATION-1 data failed check"; /* cookie wrong */ |
165 | if (GET_32BIT_MSB_FIRST(data+8) != peer_ip) |
166 | return "XDM-AUTHORIZATION-1 data failed check"; /* IP wrong */ |
167 | if ((int)GET_16BIT_MSB_FIRST(data+12) != peer_port) |
168 | return "XDM-AUTHORIZATION-1 data failed check"; /* port wrong */ |
169 | t = GET_32BIT_MSB_FIRST(data+14); |
170 | for (i = 18; i < 24; i++) |
171 | if (data[i] != 0) /* zero padding wrong */ |
172 | return "XDM-AUTHORIZATION-1 data failed check"; |
173 | tim = time(NULL); |
174 | if (abs(t - tim) > 20*60) /* 20 minute clock skew should be OK */ |
175 | return "XDM-AUTHORIZATION-1 time stamp was too far out"; |
e0e7dff8 |
176 | } |
177 | /* implement other protocols here if ever required */ |
b3ebaa28 |
178 | return NULL; |
9c964e85 |
179 | } |
180 | |
7555d6a5 |
181 | static void x11_log(Plug p, int type, SockAddr addr, int port, |
182 | const char *error_msg, int error_code) |
183 | { |
184 | /* We have no interface to the logging module here, so we drop these. */ |
185 | } |
186 | |
cbe2d68f |
187 | static int x11_closing(Plug plug, const char *error_msg, int error_code, |
32874aea |
188 | int calling_back) |
189 | { |
7e78000d |
190 | struct X11Private *pr = (struct X11Private *) plug; |
191 | |
192 | /* |
193 | * We have no way to communicate down the forwarded connection, |
194 | * so if an error occurred on the socket, we just ignore it |
195 | * and treat it like a proper close. |
196 | */ |
197 | sshfwd_close(pr->c); |
198 | x11_close(pr->s); |
199 | return 1; |
200 | } |
201 | |
32874aea |
202 | static int x11_receive(Plug plug, int urgent, char *data, int len) |
203 | { |
7e78000d |
204 | struct X11Private *pr = (struct X11Private *) plug; |
9c964e85 |
205 | |
5471d09a |
206 | if (sshfwd_write(pr->c, data, len) > 0) { |
207 | pr->throttled = 1; |
208 | sk_set_frozen(pr->s, 1); |
209 | } |
210 | |
9c964e85 |
211 | return 1; |
212 | } |
213 | |
5471d09a |
214 | static void x11_sent(Plug plug, int bufsize) |
215 | { |
216 | struct X11Private *pr = (struct X11Private *) plug; |
217 | |
218 | sshfwd_unthrottle(pr->c, bufsize); |
219 | } |
220 | |
9c964e85 |
221 | /* |
421d6835 |
222 | * When setting up X forwarding, we should send the screen number |
223 | * from the specified local display. This function extracts it from |
224 | * the display string. |
225 | */ |
226 | int x11_get_screen_number(char *display) |
227 | { |
228 | int n; |
229 | |
230 | n = strcspn(display, ":"); |
231 | if (!display[n]) |
232 | return 0; |
233 | n = strcspn(display, "."); |
234 | if (!display[n]) |
235 | return 0; |
236 | return atoi(display + n + 1); |
237 | } |
238 | |
fc0f17db |
239 | /* Find the right display, returns an allocated string */ |
240 | char *x11_display(const char *display) { |
46ed7b64 |
241 | char *ret; |
242 | if(!display || !*display) { |
243 | /* try to find platform-specific local display */ |
244 | if(!(ret = platform_get_x_display())) |
245 | /* plausible default for all platforms */ |
246 | ret = dupstr(":0"); |
247 | } else |
248 | ret = dupstr(display); |
249 | if(ret[0] == ':') { |
fc0f17db |
250 | /* no transport specified, use whatever we think is best */ |
0ca70bfc |
251 | char *s = dupcat(platform_x11_best_transport, ret, (char *)0); |
46ed7b64 |
252 | sfree(ret); |
253 | return s; |
fc0f17db |
254 | } else |
46ed7b64 |
255 | return ret; |
fc0f17db |
256 | } |
257 | |
421d6835 |
258 | /* |
9c964e85 |
259 | * Called to set up the raw connection. |
260 | * |
261 | * Returns an error message, or NULL on success. |
262 | * also, fills the SocketsStructure |
9c964e85 |
263 | */ |
cbe2d68f |
264 | const char *x11_init(Socket * s, char *display, void *c, void *auth, |
265 | const char *peeraddr, int peerport, const Config *cfg) |
32874aea |
266 | { |
302121de |
267 | static const struct plug_function_table fn_table = { |
7555d6a5 |
268 | x11_log, |
7e78000d |
269 | x11_closing, |
5471d09a |
270 | x11_receive, |
271 | x11_sent, |
272 | NULL |
7e78000d |
273 | }; |
274 | |
9c964e85 |
275 | SockAddr addr; |
276 | int port; |
cbe2d68f |
277 | const char *err; |
278 | char *dummy_realhost; |
9c964e85 |
279 | char host[128]; |
280 | int n, displaynum; |
281 | struct X11Private *pr; |
282 | |
fc0f17db |
283 | /* default display */ |
284 | display = x11_display(display); |
9c964e85 |
285 | /* |
286 | * Split up display name into host and display-number parts. |
287 | */ |
288 | n = strcspn(display, ":"); |
fc0f17db |
289 | assert(n != 0); /* x11_display() promises this */ |
9c964e85 |
290 | if (display[n]) |
32874aea |
291 | displaynum = atoi(display + n + 1); |
9c964e85 |
292 | else |
32874aea |
293 | displaynum = 0; /* sensible default */ |
294 | if (n > sizeof(host) - 1) |
295 | n = sizeof(host) - 1; |
fc0f17db |
296 | strncpy(host, display, n); |
297 | host[n] = '\0'; |
298 | sfree(display); |
299 | |
300 | if(!strcmp(host, "unix")) { |
301 | /* use AF_UNIX sockets (doesn't make sense on all platforms) */ |
302 | addr = platform_get_x11_unix_address(displaynum, |
303 | &dummy_realhost); |
304 | port = 0; /* to show we are not confused */ |
ecc0ba5b |
305 | } else { |
fc0f17db |
306 | port = 6000 + displaynum; |
307 | |
ecc0ba5b |
308 | /* |
fc0f17db |
309 | * Try to find host. |
ecc0ba5b |
310 | */ |
05581745 |
311 | addr = name_lookup(host, port, &dummy_realhost, cfg, ADDRTYPE_UNSPEC); |
fc0f17db |
312 | if ((err = sk_addr_error(addr)) != NULL) { |
313 | sk_addr_free(addr); |
314 | return err; |
315 | } |
f85e6f6e |
316 | } |
9c964e85 |
317 | |
9c964e85 |
318 | /* |
319 | * Open socket. |
320 | */ |
3d88e64d |
321 | pr = snew(struct X11Private); |
7e78000d |
322 | pr->fn = &fn_table; |
9c964e85 |
323 | pr->auth_protocol = NULL; |
302121de |
324 | pr->auth = (struct X11Auth *)auth; |
9c964e85 |
325 | pr->verified = 0; |
326 | pr->data_read = 0; |
5471d09a |
327 | pr->throttled = pr->throttle_override = 0; |
9c964e85 |
328 | pr->c = c; |
329 | |
e8fa8f62 |
330 | pr->s = *s = new_connection(addr, dummy_realhost, port, |
79bf227b |
331 | 0, 1, 0, 0, (Plug) pr, cfg); |
6518ea7b |
332 | if ((err = sk_socket_error(*s)) != NULL) { |
32874aea |
333 | sfree(pr); |
7e78000d |
334 | return err; |
335 | } |
336 | |
b3ebaa28 |
337 | /* |
338 | * See if we can make sense of the peer address we were given. |
339 | */ |
340 | { |
341 | int i[4]; |
342 | if (peeraddr && |
343 | 4 == sscanf(peeraddr, "%d.%d.%d.%d", i+0, i+1, i+2, i+3)) { |
344 | pr->peer_ip = (i[0] << 24) | (i[1] << 16) | (i[2] << 8) | i[3]; |
345 | pr->peer_port = peerport; |
346 | } else { |
347 | pr->peer_ip = 0; |
348 | pr->peer_port = -1; |
349 | } |
350 | } |
351 | |
9c964e85 |
352 | sk_set_private_ptr(*s, pr); |
9c964e85 |
353 | return NULL; |
354 | } |
355 | |
32874aea |
356 | void x11_close(Socket s) |
357 | { |
358 | struct X11Private *pr; |
d74d141c |
359 | if (!s) |
360 | return; |
361 | pr = (struct X11Private *) sk_get_private_ptr(s); |
9c964e85 |
362 | if (pr->auth_protocol) { |
32874aea |
363 | sfree(pr->auth_protocol); |
364 | sfree(pr->auth_data); |
9c964e85 |
365 | } |
366 | |
367 | sfree(pr); |
368 | |
369 | sk_close(s); |
370 | } |
371 | |
5471d09a |
372 | void x11_unthrottle(Socket s) |
373 | { |
374 | struct X11Private *pr; |
375 | if (!s) |
376 | return; |
377 | pr = (struct X11Private *) sk_get_private_ptr(s); |
378 | |
379 | pr->throttled = 0; |
380 | sk_set_frozen(s, pr->throttled || pr->throttle_override); |
381 | } |
382 | |
383 | void x11_override_throttle(Socket s, int enable) |
384 | { |
385 | struct X11Private *pr; |
386 | if (!s) |
387 | return; |
388 | pr = (struct X11Private *) sk_get_private_ptr(s); |
389 | |
390 | pr->throttle_override = enable; |
391 | sk_set_frozen(s, pr->throttled || pr->throttle_override); |
392 | } |
393 | |
9c964e85 |
394 | /* |
395 | * Called to send data down the raw connection. |
396 | */ |
5471d09a |
397 | int x11_send(Socket s, char *data, int len) |
32874aea |
398 | { |
970f2b02 |
399 | struct X11Private *pr; |
400 | if (!s) |
5471d09a |
401 | return 0; |
970f2b02 |
402 | pr = (struct X11Private *) sk_get_private_ptr(s); |
9c964e85 |
403 | |
404 | /* |
405 | * Read the first packet. |
406 | */ |
407 | while (len > 0 && pr->data_read < 12) |
32874aea |
408 | pr->firstpkt[pr->data_read++] = (unsigned char) (len--, *data++); |
9c964e85 |
409 | if (pr->data_read < 12) |
5471d09a |
410 | return 0; |
9c964e85 |
411 | |
412 | /* |
413 | * If we have not allocated the auth_protocol and auth_data |
414 | * strings, do so now. |
415 | */ |
416 | if (!pr->auth_protocol) { |
32874aea |
417 | pr->auth_plen = GET_16BIT(pr->firstpkt[0], pr->firstpkt + 6); |
418 | pr->auth_dlen = GET_16BIT(pr->firstpkt[0], pr->firstpkt + 8); |
419 | pr->auth_psize = (pr->auth_plen + 3) & ~3; |
420 | pr->auth_dsize = (pr->auth_dlen + 3) & ~3; |
421 | /* Leave room for a terminating zero, to make our lives easier. */ |
3d88e64d |
422 | pr->auth_protocol = snewn(pr->auth_psize + 1, char); |
92d60585 |
423 | pr->auth_data = snewn(pr->auth_dsize, unsigned char); |
9c964e85 |
424 | } |
425 | |
426 | /* |
427 | * Read the auth_protocol and auth_data strings. |
428 | */ |
429 | while (len > 0 && pr->data_read < 12 + pr->auth_psize) |
32874aea |
430 | pr->auth_protocol[pr->data_read++ - 12] = (len--, *data++); |
9c964e85 |
431 | while (len > 0 && pr->data_read < 12 + pr->auth_psize + pr->auth_dsize) |
32874aea |
432 | pr->auth_data[pr->data_read++ - 12 - |
433 | pr->auth_psize] = (unsigned char) (len--, *data++); |
9c964e85 |
434 | if (pr->data_read < 12 + pr->auth_psize + pr->auth_dsize) |
5471d09a |
435 | return 0; |
9c964e85 |
436 | |
437 | /* |
438 | * If we haven't verified the authentication, do so now. |
439 | */ |
440 | if (!pr->verified) { |
b3ebaa28 |
441 | char *err; |
32874aea |
442 | |
443 | pr->auth_protocol[pr->auth_plen] = '\0'; /* ASCIZ */ |
b3ebaa28 |
444 | err = x11_verify(pr->peer_ip, pr->peer_port, |
445 | pr->auth, pr->auth_protocol, |
302121de |
446 | pr->auth_data, pr->auth_dlen); |
32874aea |
447 | |
448 | /* |
449 | * If authentication failed, construct and send an error |
450 | * packet, then terminate the connection. |
451 | */ |
b3ebaa28 |
452 | if (err) { |
453 | char *message; |
454 | int msglen, msgsize; |
455 | unsigned char *reply; |
456 | |
457 | message = dupprintf("PuTTY X11 proxy: %s", err); |
458 | msglen = strlen(message); |
3d88e64d |
459 | reply = snewn(8 + msglen+1 + 4, unsigned char); /* include zero */ |
b3ebaa28 |
460 | msgsize = (msglen + 3) & ~3; |
32874aea |
461 | reply[0] = 0; /* failure */ |
462 | reply[1] = msglen; /* length of reason string */ |
463 | memcpy(reply + 2, pr->firstpkt + 2, 4); /* major/minor proto vsn */ |
75105663 |
464 | PUT_16BIT(pr->firstpkt[0], reply + 6, msgsize >> 2);/* data len */ |
32874aea |
465 | memset(reply + 8, 0, msgsize); |
466 | memcpy(reply + 8, message, msglen); |
f28e6b7c |
467 | sshfwd_write(pr->c, (char *)reply, 8 + msgsize); |
32874aea |
468 | sshfwd_close(pr->c); |
469 | x11_close(s); |
b3ebaa28 |
470 | sfree(reply); |
471 | sfree(message); |
5471d09a |
472 | return 0; |
32874aea |
473 | } |
474 | |
475 | /* |
476 | * Now we know we're going to accept the connection. Strip |
e0e7dff8 |
477 | * the fake auth data, and optionally put real auth data in |
478 | * instead. |
32874aea |
479 | */ |
e0e7dff8 |
480 | { |
481 | char realauthdata[64]; |
482 | int realauthlen = 0; |
483 | int authstrlen = strlen(x11_authnames[pr->auth->realproto]); |
2f92b717 |
484 | unsigned long ip; |
485 | int port; |
e0e7dff8 |
486 | static const char zeroes[4] = { 0,0,0,0 }; |
487 | |
488 | if (pr->auth->realproto == X11_MIT) { |
489 | assert(pr->auth->reallen <= lenof(realauthdata)); |
490 | realauthlen = pr->auth->reallen; |
491 | memcpy(realauthdata, pr->auth->realdata, realauthlen); |
2f92b717 |
492 | } else if (pr->auth->realproto == X11_XDM && |
493 | pr->auth->reallen == 16 && |
494 | sk_getxdmdata(s, &ip, &port)) { |
495 | time_t t; |
496 | realauthlen = 24; |
497 | memset(realauthdata, 0, 24); |
498 | memcpy(realauthdata, pr->auth->realdata, 8); |
499 | PUT_32BIT_MSB_FIRST(realauthdata+8, ip); |
500 | PUT_16BIT_MSB_FIRST(realauthdata+12, port); |
501 | t = time(NULL); |
502 | PUT_32BIT_MSB_FIRST(realauthdata+14, t); |
6e7f5aee |
503 | des_encrypt_xdmauth(pr->auth->realdata+9, |
504 | (unsigned char *)realauthdata, 24); |
2f92b717 |
505 | } |
e0e7dff8 |
506 | /* implement other auth methods here if required */ |
507 | |
508 | PUT_16BIT(pr->firstpkt[0], pr->firstpkt + 6, authstrlen); |
509 | PUT_16BIT(pr->firstpkt[0], pr->firstpkt + 8, realauthlen); |
510 | |
511 | sk_write(s, (char *)pr->firstpkt, 12); |
512 | |
513 | if (authstrlen) { |
514 | sk_write(s, x11_authnames[pr->auth->realproto], authstrlen); |
515 | sk_write(s, zeroes, 3 & (-authstrlen)); |
516 | } |
517 | if (realauthlen) { |
518 | sk_write(s, realauthdata, realauthlen); |
519 | sk_write(s, zeroes, 3 & (-realauthlen)); |
520 | } |
521 | } |
32874aea |
522 | pr->verified = 1; |
9c964e85 |
523 | } |
524 | |
525 | /* |
526 | * After initialisation, just copy data simply. |
527 | */ |
528 | |
5471d09a |
529 | return sk_write(s, data, len); |
9c964e85 |
530 | } |