diff options
author | djm@openbsd.org <djm@openbsd.org> | 2017-04-30 23:28:41 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2017-05-01 10:05:06 +1000 |
commit | 930e8d2827853bc2e196c20c3e000263cc87fb75 (patch) | |
tree | d16b2923fab9253da5694a4e74b27de6c4b9b7d8 /channels.c | |
parent | a3710d5d529a34b8f56aa62db798c70e85d576a0 (diff) |
upstream commit
obliterate ssh1.h and some dead code that used it
ok markus@
Upstream-ID: 1ca9159a9fb95618f9d51e069ac8e1131a087343
Diffstat (limited to 'channels.c')
-rw-r--r-- | channels.c | 163 |
1 files changed, 1 insertions, 162 deletions
diff --git a/channels.c b/channels.c index 5a7e56ed0..4092a6710 100644 --- a/channels.c +++ b/channels.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: channels.c,v 1.358 2017/04/30 23:13:25 djm Exp $ */ | 1 | /* $OpenBSD: channels.c,v 1.359 2017/04/30 23:28:41 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -69,7 +69,6 @@ | |||
69 | #include "openbsd-compat/sys-queue.h" | 69 | #include "openbsd-compat/sys-queue.h" |
70 | #include "xmalloc.h" | 70 | #include "xmalloc.h" |
71 | #include "ssh.h" | 71 | #include "ssh.h" |
72 | #include "ssh1.h" | ||
73 | #include "ssh2.h" | 72 | #include "ssh2.h" |
74 | #include "ssherr.h" | 73 | #include "ssherr.h" |
75 | #include "packet.h" | 74 | #include "packet.h" |
@@ -2621,46 +2620,6 @@ channel_input_ieof(int type, u_int32_t seq, void *ctxt) | |||
2621 | return 0; | 2620 | return 0; |
2622 | } | 2621 | } |
2623 | 2622 | ||
2624 | /* ARGSUSED */ | ||
2625 | int | ||
2626 | channel_input_close(int type, u_int32_t seq, void *ctxt) | ||
2627 | { | ||
2628 | int id; | ||
2629 | Channel *c; | ||
2630 | |||
2631 | id = packet_get_int(); | ||
2632 | packet_check_eom(); | ||
2633 | c = channel_lookup(id); | ||
2634 | if (c == NULL) | ||
2635 | packet_disconnect("Received close for nonexistent channel %d.", id); | ||
2636 | if (channel_proxy_upstream(c, type, seq, ctxt)) | ||
2637 | return 0; | ||
2638 | /* | ||
2639 | * Send a confirmation that we have closed the channel and no more | ||
2640 | * data is coming for it. | ||
2641 | */ | ||
2642 | packet_start(SSH_MSG_CHANNEL_CLOSE_CONFIRMATION); | ||
2643 | packet_put_int(c->remote_id); | ||
2644 | packet_send(); | ||
2645 | |||
2646 | /* | ||
2647 | * If the channel is in closed state, we have sent a close request, | ||
2648 | * and the other side will eventually respond with a confirmation. | ||
2649 | * Thus, we cannot free the channel here, because then there would be | ||
2650 | * no-one to receive the confirmation. The channel gets freed when | ||
2651 | * the confirmation arrives. | ||
2652 | */ | ||
2653 | if (c->type != SSH_CHANNEL_CLOSED) { | ||
2654 | /* | ||
2655 | * Not a closed channel - mark it as draining, which will | ||
2656 | * cause it to be freed later. | ||
2657 | */ | ||
2658 | buffer_clear(&c->input); | ||
2659 | c->type = SSH_CHANNEL_OUTPUT_DRAINING; | ||
2660 | } | ||
2661 | return 0; | ||
2662 | } | ||
2663 | |||
2664 | /* proto version 1.5 overloads CLOSE_CONFIRMATION with OCLOSE */ | 2623 | /* proto version 1.5 overloads CLOSE_CONFIRMATION with OCLOSE */ |
2665 | /* ARGSUSED */ | 2624 | /* ARGSUSED */ |
2666 | int | 2625 | int |
@@ -2819,38 +2778,6 @@ channel_input_window_adjust(int type, u_int32_t seq, void *ctxt) | |||
2819 | 2778 | ||
2820 | /* ARGSUSED */ | 2779 | /* ARGSUSED */ |
2821 | int | 2780 | int |
2822 | channel_input_port_open(int type, u_int32_t seq, void *ctxt) | ||
2823 | { | ||
2824 | Channel *c = NULL; | ||
2825 | u_short host_port; | ||
2826 | char *host, *originator_string; | ||
2827 | int remote_id; | ||
2828 | |||
2829 | remote_id = packet_get_int(); | ||
2830 | host = packet_get_string(NULL); | ||
2831 | host_port = packet_get_int(); | ||
2832 | |||
2833 | if (packet_get_protocol_flags() & SSH_PROTOFLAG_HOST_IN_FWD_OPEN) { | ||
2834 | originator_string = packet_get_string(NULL); | ||
2835 | } else { | ||
2836 | originator_string = xstrdup("unknown (remote did not supply name)"); | ||
2837 | } | ||
2838 | packet_check_eom(); | ||
2839 | c = channel_connect_to_port(host, host_port, | ||
2840 | "connected socket", originator_string, NULL, NULL); | ||
2841 | free(originator_string); | ||
2842 | free(host); | ||
2843 | if (c == NULL) { | ||
2844 | packet_start(SSH_MSG_CHANNEL_OPEN_FAILURE); | ||
2845 | packet_put_int(remote_id); | ||
2846 | packet_send(); | ||
2847 | } else | ||
2848 | c->remote_id = remote_id; | ||
2849 | return 0; | ||
2850 | } | ||
2851 | |||
2852 | /* ARGSUSED */ | ||
2853 | int | ||
2854 | channel_input_status_confirm(int type, u_int32_t seq, void *ctxt) | 2781 | channel_input_status_confirm(int type, u_int32_t seq, void *ctxt) |
2855 | { | 2782 | { |
2856 | Channel *c; | 2783 | Channel *c; |
@@ -4256,81 +4183,6 @@ x11_connect_display(void) | |||
4256 | } | 4183 | } |
4257 | 4184 | ||
4258 | /* | 4185 | /* |
4259 | * This is called when SSH_SMSG_X11_OPEN is received. The packet contains | ||
4260 | * the remote channel number. We should do whatever we want, and respond | ||
4261 | * with either SSH_MSG_OPEN_CONFIRMATION or SSH_MSG_OPEN_FAILURE. | ||
4262 | */ | ||
4263 | |||
4264 | /* ARGSUSED */ | ||
4265 | int | ||
4266 | x11_input_open(int type, u_int32_t seq, void *ctxt) | ||
4267 | { | ||
4268 | Channel *c = NULL; | ||
4269 | int remote_id, sock = 0; | ||
4270 | char *remote_host; | ||
4271 | |||
4272 | debug("Received X11 open request."); | ||
4273 | |||
4274 | remote_id = packet_get_int(); | ||
4275 | |||
4276 | if (packet_get_protocol_flags() & SSH_PROTOFLAG_HOST_IN_FWD_OPEN) { | ||
4277 | remote_host = packet_get_string(NULL); | ||
4278 | } else { | ||
4279 | remote_host = xstrdup("unknown (remote did not supply name)"); | ||
4280 | } | ||
4281 | packet_check_eom(); | ||
4282 | |||
4283 | /* Obtain a connection to the real X display. */ | ||
4284 | sock = x11_connect_display(); | ||
4285 | if (sock != -1) { | ||
4286 | /* Allocate a channel for this connection. */ | ||
4287 | c = channel_new("connected x11 socket", | ||
4288 | SSH_CHANNEL_X11_OPEN, sock, sock, -1, 0, 0, 0, | ||
4289 | remote_host, 1); | ||
4290 | c->remote_id = remote_id; | ||
4291 | c->force_drain = 1; | ||
4292 | } | ||
4293 | free(remote_host); | ||
4294 | if (c == NULL) { | ||
4295 | /* Send refusal to the remote host. */ | ||
4296 | packet_start(SSH_MSG_CHANNEL_OPEN_FAILURE); | ||
4297 | packet_put_int(remote_id); | ||
4298 | } else { | ||
4299 | /* Send a confirmation to the remote host. */ | ||
4300 | packet_start(SSH_MSG_CHANNEL_OPEN_CONFIRMATION); | ||
4301 | packet_put_int(remote_id); | ||
4302 | packet_put_int(c->self); | ||
4303 | } | ||
4304 | packet_send(); | ||
4305 | return 0; | ||
4306 | } | ||
4307 | |||
4308 | /* dummy protocol handler that denies SSH-1 requests (agent/x11) */ | ||
4309 | /* ARGSUSED */ | ||
4310 | int | ||
4311 | deny_input_open(int type, u_int32_t seq, void *ctxt) | ||
4312 | { | ||
4313 | int rchan = packet_get_int(); | ||
4314 | |||
4315 | switch (type) { | ||
4316 | case SSH_SMSG_AGENT_OPEN: | ||
4317 | error("Warning: ssh server tried agent forwarding."); | ||
4318 | break; | ||
4319 | case SSH_SMSG_X11_OPEN: | ||
4320 | error("Warning: ssh server tried X11 forwarding."); | ||
4321 | break; | ||
4322 | default: | ||
4323 | error("deny_input_open: type %d", type); | ||
4324 | break; | ||
4325 | } | ||
4326 | error("Warning: this is probably a break-in attempt by a malicious server."); | ||
4327 | packet_start(SSH_MSG_CHANNEL_OPEN_FAILURE); | ||
4328 | packet_put_int(rchan); | ||
4329 | packet_send(); | ||
4330 | return 0; | ||
4331 | } | ||
4332 | |||
4333 | /* | ||
4334 | * Requests forwarding of X11 connections, generates fake authentication | 4186 | * Requests forwarding of X11 connections, generates fake authentication |
4335 | * data, and enables authentication spoofing. | 4187 | * data, and enables authentication spoofing. |
4336 | * This should be called in the client only. | 4188 | * This should be called in the client only. |
@@ -4394,16 +4246,3 @@ x11_request_forwarding_with_spoofing(int client_session_id, const char *disp, | |||
4394 | packet_write_wait(); | 4246 | packet_write_wait(); |
4395 | free(new_data); | 4247 | free(new_data); |
4396 | } | 4248 | } |
4397 | |||
4398 | |||
4399 | /* -- agent forwarding */ | ||
4400 | |||
4401 | /* Sends a message to the server to request authentication fd forwarding. */ | ||
4402 | |||
4403 | void | ||
4404 | auth_request_forwarding(void) | ||
4405 | { | ||
4406 | packet_start(SSH_CMSG_AGENT_REQUEST_FORWARDING); | ||
4407 | packet_send(); | ||
4408 | packet_write_wait(); | ||
4409 | } | ||