Lines Matching refs:ssh
169 static void client_init_dispatch(struct ssh *ssh);
246 set_control_persist_exit_time(struct ssh *ssh) in set_control_persist_exit_time() argument
252 } else if (channel_still_open(ssh)) { in set_control_persist_exit_time()
290 client_x11_get_proto(struct ssh *ssh, const char *display, in client_x11_get_proto() argument
385 channel_set_x11_refuse_time(ssh, in client_x11_get_proto()
461 client_check_window_change(struct ssh *ssh) in client_check_window_change() argument
467 channel_send_window_changes(ssh); in client_check_window_change()
471 client_global_request_reply(int type, u_int32_t seq, struct ssh *ssh) in client_global_request_reply() argument
478 gc->cb(ssh, type, seq, gc->ctx); in client_global_request_reply()
484 ssh_packet_set_alive_timeouts(ssh, 0); in client_global_request_reply()
496 server_alive_check(struct ssh *ssh) in server_alive_check() argument
500 if (ssh_packet_inc_alive_timeouts(ssh) > options.server_alive_count_max) { in server_alive_check()
504 if ((r = sshpkt_start(ssh, SSH2_MSG_GLOBAL_REQUEST)) != 0 || in server_alive_check()
505 (r = sshpkt_put_cstring(ssh, "keepalive@openssh.com")) != 0 || in server_alive_check()
506 (r = sshpkt_put_u8(ssh, 1)) != 0 || /* boolean: want reply */ in server_alive_check()
507 (r = sshpkt_send(ssh)) != 0) in server_alive_check()
516 send_chaff(struct ssh *ssh) in send_chaff() argument
520 if (ssh->kex == NULL || (ssh->kex->flags & KEX_HAS_PING) == 0) in send_chaff()
528 if ((r = sshpkt_start(ssh, SSH2_MSG_PING)) != 0 || in send_chaff()
529 (r = sshpkt_put_cstring(ssh, "PING!")) != 0 || in send_chaff()
530 (r = sshpkt_send(ssh)) != 0) in send_chaff()
577 obfuscate_keystroke_timing(struct ssh *ssh, struct timespec *timeout, in obfuscate_keystroke_timing() argument
593 if (!channel_tty_open(ssh) || quit_pending) { in obfuscate_keystroke_timing()
596 } else if (ssh_packet_is_rekeying(ssh)) { in obfuscate_keystroke_timing()
599 } else if (!ssh_packet_interactive_data_to_write(ssh) && in obfuscate_keystroke_timing()
600 ssh_packet_have_data_to_write(ssh)) { in obfuscate_keystroke_timing()
604 ssh_packet_have_data_to_write(ssh)) { in obfuscate_keystroke_timing()
612 !ssh_packet_have_data_to_write(ssh)) { in obfuscate_keystroke_timing()
614 if (send_chaff(ssh)) in obfuscate_keystroke_timing()
634 if (!active && ssh_packet_interactive_data_to_write(ssh) && in obfuscate_keystroke_timing()
635 channel_did_enqueue && ssh_packet_have_data_to_write(ssh)) { in obfuscate_keystroke_timing()
684 client_wait_until_can_do_something(struct ssh *ssh, struct pollfd **pfdp, in client_wait_until_can_do_something() argument
696 channel_prepare_poll(ssh, pfdp, npfd_allocp, npfd_activep, 2, &timeout); in client_wait_until_can_do_something()
701 if (session_closed && !channel_still_open(ssh) && in client_wait_until_can_do_something()
702 !ssh_packet_have_data_to_write(ssh)) { in client_wait_until_can_do_something()
709 oready = obfuscate_keystroke_timing(ssh, &timeout, channel_did_enqueue); in client_wait_until_can_do_something()
715 (*pfdp)[1].events = (oready && ssh_packet_have_data_to_write(ssh)) ? in client_wait_until_can_do_something()
723 set_control_persist_exit_time(ssh); in client_wait_until_can_do_something()
728 if (options.rekey_interval > 0 && !ssh_packet_is_rekeying(ssh)) { in client_wait_until_can_do_something()
730 ssh_packet_get_rekey_timeout(ssh)); in client_wait_until_can_do_something()
760 server_alive_check(ssh); in client_wait_until_can_do_something()
791 client_process_net_input(struct ssh *ssh) in client_process_net_input() argument
800 if ((r = ssh_packet_process_read(ssh, connection_in)) == 0) in client_process_net_input()
815 client_status_confirm(struct ssh *ssh, int type, Channel *c, void *ctx) in client_status_confirm() argument
869 mux_tty_alloc_failed(ssh, c); in client_status_confirm()
871 chan_read_failed(ssh, c); in client_status_confirm()
872 chan_write_failed(ssh, c); in client_status_confirm()
879 client_abandon_status_confirm(struct ssh *ssh, Channel *c, void *ctx) in client_abandon_status_confirm() argument
885 client_expect_confirm(struct ssh *ssh, int id, const char *request, in client_expect_confirm() argument
893 channel_register_status_confirm(ssh, id, client_status_confirm, in client_expect_confirm()
985 process_cmdline(struct ssh *ssh) in process_cmdline() argument
1059 ok = channel_request_rforward_cancel(ssh, &fwd) == 0; in process_cmdline()
1061 ok = channel_cancel_lport_listener(ssh, &fwd, in process_cmdline()
1064 ok = channel_cancel_lport_listener(ssh, &fwd, in process_cmdline()
1085 if (!channel_setup_local_fwd_listener(ssh, &fwd, in process_cmdline()
1091 if (channel_request_remote_forwarding(ssh, &fwd) < 0) { in process_cmdline()
1171 process_escapes(struct ssh *ssh, Channel *c, in process_escapes() argument
1204 channel_force_close(ssh, c, 1); in process_escapes()
1242 channel_request_start(ssh, c->self, "break", 0); in process_escapes()
1243 if ((r = sshpkt_put_u32(ssh, 1000)) != 0 || in process_escapes()
1244 (r = sshpkt_send(ssh)) != 0) in process_escapes()
1249 if (ssh->compat & SSH_BUG_NOREKEY) in process_escapes()
1294 channel_stop_listening(ssh); in process_escapes()
1325 s = channel_open_message(ssh); in process_escapes()
1340 process_cmdline(ssh); in process_escapes()
1393 client_process_buffered_input_packets(struct ssh *ssh) in client_process_buffered_input_packets() argument
1395 ssh_dispatch_run_fatal(ssh, DISPATCH_NONBLOCK, &quit_pending); in client_process_buffered_input_packets()
1414 client_filter_cleanup(struct ssh *ssh, int cid, void *ctx) in client_filter_cleanup() argument
1420 client_simple_escape_filter(struct ssh *ssh, Channel *c, char *buf, int len) in client_simple_escape_filter() argument
1425 return process_escapes(ssh, c, c->input, c->output, c->extended, in client_simple_escape_filter()
1430 client_channel_closed(struct ssh *ssh, int id, int force, void *arg) in client_channel_closed() argument
1432 channel_cancel_cleanup(ssh, id); in client_channel_closed()
1444 client_loop(struct ssh *ssh, int have_pty, int escape_char_arg, in client_loop() argument
1497 connection_in = ssh_packet_get_connection_in(ssh); in client_loop()
1498 connection_out = ssh_packet_get_connection_out(ssh); in client_loop()
1506 client_init_dispatch(ssh); in client_loop()
1527 channel_register_filter(ssh, session_ident, in client_loop()
1533 channel_register_cleanup(ssh, session_ident, in client_loop()
1551 client_process_buffered_input_packets(ssh); in client_loop()
1553 if (session_closed && !channel_still_open(ssh)) in client_loop()
1556 if (ssh_packet_is_rekeying(ssh)) { in client_loop()
1561 if ((r = kex_start_rekex(ssh)) != 0) in client_loop()
1569 if (ssh_packet_not_very_much_data_to_write(ssh)) in client_loop()
1570 channel_did_enqueue = channel_output_poll(ssh); in client_loop()
1576 client_check_window_change(ssh); in client_loop()
1586 client_wait_until_can_do_something(ssh, &pfd, &npfd_alloc, in client_loop()
1596 channel_after_poll(ssh, pfd, npfd_active); in client_loop()
1600 client_process_net_input(ssh); in client_loop()
1606 if ((r = ssh_packet_check_rekey(ssh)) != 0) in client_loop()
1614 if ((r = ssh_packet_write_poll(ssh)) != 0) { in client_loop()
1615 sshpkt_fatal(ssh, r, in client_loop()
1639 if ((r = sshpkt_start(ssh, SSH2_MSG_DISCONNECT)) != 0 || in client_loop()
1640 (r = sshpkt_put_u32(ssh, SSH2_DISCONNECT_BY_APPLICATION)) != 0 || in client_loop()
1641 (r = sshpkt_put_cstring(ssh, "disconnected by user")) != 0 || in client_loop()
1642 (r = sshpkt_put_cstring(ssh, "")) != 0 || /* language tag */ in client_loop()
1643 (r = sshpkt_send(ssh)) != 0 || in client_loop()
1644 (r = ssh_packet_write_wait(ssh)) != 0) in client_loop()
1647 channel_free_all(ssh); in client_loop()
1691 ssh_packet_get_bytes(ssh, &ibytes, &obytes); in client_loop()
1705 client_request_forwarded_tcpip(struct ssh *ssh, const char *request_type, in client_request_forwarded_tcpip() argument
1715 if ((r = sshpkt_get_cstring(ssh, &listen_address, NULL)) != 0 || in client_request_forwarded_tcpip()
1716 (r = sshpkt_get_u32(ssh, &listen_port)) != 0 || in client_request_forwarded_tcpip()
1717 (r = sshpkt_get_cstring(ssh, &originator_address, NULL)) != 0 || in client_request_forwarded_tcpip()
1718 (r = sshpkt_get_u32(ssh, &originator_port)) != 0 || in client_request_forwarded_tcpip()
1719 (r = sshpkt_get_end(ssh)) != 0) in client_request_forwarded_tcpip()
1730 c = channel_connect_by_listen_address(ssh, in client_request_forwarded_tcpip()
1765 client_request_forwarded_streamlocal(struct ssh *ssh, in client_request_forwarded_streamlocal() argument
1773 if ((r = sshpkt_get_cstring(ssh, &listen_path, NULL)) != 0 || in client_request_forwarded_streamlocal()
1774 (r = sshpkt_get_string(ssh, NULL, NULL)) != 0 || /* reserved */ in client_request_forwarded_streamlocal()
1775 (r = sshpkt_get_end(ssh)) != 0) in client_request_forwarded_streamlocal()
1780 c = channel_connect_by_listen_path(ssh, listen_path, in client_request_forwarded_streamlocal()
1787 client_request_x11(struct ssh *ssh, const char *request_type, int rchan) in client_request_x11() argument
1805 if ((r = sshpkt_get_cstring(ssh, &originator, NULL)) != 0 || in client_request_x11()
1806 (r = sshpkt_get_u32(ssh, &originator_port)) != 0 || in client_request_x11()
1807 (r = sshpkt_get_end(ssh)) != 0) in client_request_x11()
1814 sock = x11_connect_display(ssh); in client_request_x11()
1817 c = channel_new(ssh, "x11-connection", in client_request_x11()
1825 client_request_agent(struct ssh *ssh, const char *request_type, int rchan) in client_request_agent() argument
1846 if ((r = ssh_agent_bind_hostkey(sock, ssh->kex->initial_hostkey, in client_request_agent()
1847 ssh->kex->session_id, ssh->kex->initial_sig, 1)) == 0) in client_request_agent()
1852 c = channel_new(ssh, "agent-connection", in client_request_agent()
1861 client_request_tun_fwd(struct ssh *ssh, int tun_mode, in client_request_tun_fwd() argument
1880 c = channel_new(ssh, "tun-connection", SSH_CHANNEL_OPENING, fd, fd, -1, in client_request_tun_fwd()
1886 channel_register_filter(ssh, c->self, sys_tun_infilter, in client_request_tun_fwd()
1891 channel_register_open_confirm(ssh, c->self, cb, cbctx); in client_request_tun_fwd()
1893 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN)) != 0 || in client_request_tun_fwd()
1894 (r = sshpkt_put_cstring(ssh, "tun@openssh.com")) != 0 || in client_request_tun_fwd()
1895 (r = sshpkt_put_u32(ssh, c->self)) != 0 || in client_request_tun_fwd()
1896 (r = sshpkt_put_u32(ssh, c->local_window_max)) != 0 || in client_request_tun_fwd()
1897 (r = sshpkt_put_u32(ssh, c->local_maxpacket)) != 0 || in client_request_tun_fwd()
1898 (r = sshpkt_put_u32(ssh, tun_mode)) != 0 || in client_request_tun_fwd()
1899 (r = sshpkt_put_u32(ssh, remote_tun)) != 0 || in client_request_tun_fwd()
1900 (r = sshpkt_send(ssh)) != 0) in client_request_tun_fwd()
1901 sshpkt_fatal(ssh, r, "%s: send reply", __func__); in client_request_tun_fwd()
1908 client_input_channel_open(int type, u_int32_t seq, struct ssh *ssh) in client_input_channel_open() argument
1917 if ((r = sshpkt_get_cstring(ssh, &ctype, &len)) != 0 || in client_input_channel_open()
1918 (r = sshpkt_get_u32(ssh, &rchan)) != 0 || in client_input_channel_open()
1919 (r = sshpkt_get_u32(ssh, &rwindow)) != 0 || in client_input_channel_open()
1920 (r = sshpkt_get_u32(ssh, &rmaxpack)) != 0) in client_input_channel_open()
1927 c = client_request_forwarded_tcpip(ssh, ctype, rchan, rwindow, in client_input_channel_open()
1930 c = client_request_forwarded_streamlocal(ssh, ctype, rchan); in client_input_channel_open()
1932 c = client_request_x11(ssh, ctype, rchan); in client_input_channel_open()
1934 c = client_request_agent(ssh, ctype, rchan); in client_input_channel_open()
1945 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION)) != 0 || in client_input_channel_open()
1946 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in client_input_channel_open()
1947 (r = sshpkt_put_u32(ssh, c->self)) != 0 || in client_input_channel_open()
1948 (r = sshpkt_put_u32(ssh, c->local_window)) != 0 || in client_input_channel_open()
1949 (r = sshpkt_put_u32(ssh, c->local_maxpacket)) != 0 || in client_input_channel_open()
1950 (r = sshpkt_send(ssh)) != 0) in client_input_channel_open()
1951 sshpkt_fatal(ssh, r, "%s: send reply", __func__); in client_input_channel_open()
1955 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN_FAILURE)) != 0 || in client_input_channel_open()
1956 (r = sshpkt_put_u32(ssh, rchan)) != 0 || in client_input_channel_open()
1957 (r = sshpkt_put_u32(ssh, SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED)) != 0 || in client_input_channel_open()
1958 (r = sshpkt_put_cstring(ssh, "open failed")) != 0 || in client_input_channel_open()
1959 (r = sshpkt_put_cstring(ssh, "")) != 0 || in client_input_channel_open()
1960 (r = sshpkt_send(ssh)) != 0) in client_input_channel_open()
1961 sshpkt_fatal(ssh, r, "%s: send failure", __func__); in client_input_channel_open()
1970 client_input_channel_req(int type, u_int32_t seq, struct ssh *ssh) in client_input_channel_req() argument
1978 if ((r = sshpkt_get_u32(ssh, &id)) != 0) in client_input_channel_req()
1981 c = channel_lookup(ssh, id); in client_input_channel_req()
1982 if (channel_proxy_upstream(c, type, seq, ssh)) in client_input_channel_req()
1984 if ((r = sshpkt_get_cstring(ssh, &rtype, NULL)) != 0 || in client_input_channel_req()
1985 (r = sshpkt_get_u8(ssh, &reply)) != 0) in client_input_channel_req()
1995 if ((r = sshpkt_get_end(ssh)) != 0) in client_input_channel_req()
1997 chan_rcvd_eow(ssh, c); in client_input_channel_req()
1999 if ((r = sshpkt_get_u32(ssh, &exitval)) != 0) in client_input_channel_req()
2002 mux_exit_message(ssh, c, exitval); in client_input_channel_req()
2013 if ((r = sshpkt_get_end(ssh)) != 0) in client_input_channel_req()
2019 if ((r = sshpkt_start(ssh, success ? in client_input_channel_req()
2021 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in client_input_channel_req()
2022 (r = sshpkt_send(ssh)) != 0) in client_input_channel_req()
2023 sshpkt_fatal(ssh, r, "%s: send failure", __func__); in client_input_channel_req()
2347 client_global_hostkeys_prove_confirm(struct ssh *ssh, int type, in client_global_hostkeys_prove_confirm() argument
2368 ssh->kex->hostkey_alg)) == KEY_RSA) in client_global_hostkeys_prove_confirm()
2369 rsa_kexalg = ssh->kex->hostkey_alg; in client_global_hostkeys_prove_confirm()
2386 ssh->kex->session_id)) != 0 || in client_global_hostkeys_prove_confirm()
2390 if ((r = sshpkt_get_string_direct(ssh, &sig, &siglen)) != 0) { in client_global_hostkeys_prove_confirm()
2432 if ((r = sshpkt_get_end(ssh)) != 0) { in client_global_hostkeys_prove_confirm()
2470 client_input_hostkeys(struct ssh *ssh) in client_input_hostkeys() argument
2490 while (ssh_packet_remaining(ssh) > 0) { in client_input_hostkeys()
2493 if ((r = sshpkt_get_string_direct(ssh, &blob, &len)) != 0) { in client_input_hostkeys()
2636 if ((r = sshpkt_start(ssh, SSH2_MSG_GLOBAL_REQUEST)) != 0 || in client_input_hostkeys()
2637 (r = sshpkt_put_cstring(ssh, in client_input_hostkeys()
2639 (r = sshpkt_put_u8(ssh, 1)) != 0) /* bool: want reply */ in client_input_hostkeys()
2648 (r = sshpkt_put_stringb(ssh, buf)) != 0) in client_input_hostkeys()
2651 if ((r = sshpkt_send(ssh)) != 0) in client_input_hostkeys()
2676 client_input_global_request(int type, u_int32_t seq, struct ssh *ssh) in client_input_global_request() argument
2682 if ((r = sshpkt_get_cstring(ssh, &rtype, NULL)) != 0 || in client_input_global_request()
2683 (r = sshpkt_get_u8(ssh, &want_reply)) != 0) in client_input_global_request()
2688 success = client_input_hostkeys(ssh); in client_input_global_request()
2690 if ((r = sshpkt_start(ssh, success ? SSH2_MSG_REQUEST_SUCCESS : in client_input_global_request()
2692 (r = sshpkt_send(ssh)) != 0 || in client_input_global_request()
2693 (r = ssh_packet_write_wait(ssh)) != 0) in client_input_global_request()
2703 client_send_env(struct ssh *ssh, int id, const char *name, const char *val) in client_send_env() argument
2708 channel_request_start(ssh, id, "env", 0); in client_send_env()
2709 if ((r = sshpkt_put_cstring(ssh, name)) != 0 || in client_send_env()
2710 (r = sshpkt_put_cstring(ssh, val)) != 0 || in client_send_env()
2711 (r = sshpkt_send(ssh)) != 0) in client_send_env()
2716 client_session2_setup(struct ssh *ssh, int id, int want_tty, int want_subsystem, in client_session2_setup() argument
2727 if ((c = channel_lookup(ssh, id)) == NULL) in client_session2_setup()
2730 ssh_packet_set_interactive(ssh, want_tty, in client_session2_setup()
2740 channel_request_start(ssh, id, "pty-req", 1); in client_session2_setup()
2741 client_expect_confirm(ssh, id, "PTY allocation", CONFIRM_TTY); in client_session2_setup()
2742 if ((r = sshpkt_put_cstring(ssh, term != NULL ? term : "")) in client_session2_setup()
2744 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_col)) != 0 || in client_session2_setup()
2745 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_row)) != 0 || in client_session2_setup()
2746 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_xpixel)) != 0 || in client_session2_setup()
2747 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_ypixel)) != 0) in client_session2_setup()
2751 ssh_tty_make_modes(ssh, -1, tiop); in client_session2_setup()
2752 if ((r = sshpkt_send(ssh)) != 0) in client_session2_setup()
2782 client_send_env(ssh, id, name, val); in client_session2_setup()
2794 client_send_env(ssh, id, name, val); in client_session2_setup()
2805 channel_request_start(ssh, id, "subsystem", 1); in client_session2_setup()
2806 client_expect_confirm(ssh, id, "subsystem", in client_session2_setup()
2811 channel_request_start(ssh, id, "exec", 1); in client_session2_setup()
2812 client_expect_confirm(ssh, id, "exec", CONFIRM_CLOSE); in client_session2_setup()
2814 if ((r = sshpkt_put_stringb(ssh, cmd)) != 0 || in client_session2_setup()
2815 (r = sshpkt_send(ssh)) != 0) in client_session2_setup()
2818 channel_request_start(ssh, id, "shell", 1); in client_session2_setup()
2819 client_expect_confirm(ssh, id, "shell", CONFIRM_CLOSE); in client_session2_setup()
2820 if ((r = sshpkt_send(ssh)) != 0) in client_session2_setup()
2829 client_init_dispatch(struct ssh *ssh) in client_init_dispatch() argument
2831 ssh_dispatch_init(ssh, &dispatch_protocol_error); in client_init_dispatch()
2833 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_CLOSE, &channel_input_oclose); in client_init_dispatch()
2834 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_DATA, &channel_input_data); in client_init_dispatch()
2835 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_EOF, &channel_input_ieof); in client_init_dispatch()
2836 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_EXTENDED_DATA, &channel_input_extended_data); in client_init_dispatch()
2837 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_OPEN, &client_input_channel_open); in client_init_dispatch()
2838 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, &channel_input_open_confirmation); in client_init_dispatch()
2839 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure); in client_init_dispatch()
2840 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_REQUEST, &client_input_channel_req); in client_init_dispatch()
2841 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust); in client_init_dispatch()
2842 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_SUCCESS, &channel_input_status_confirm); in client_init_dispatch()
2843 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_FAILURE, &channel_input_status_confirm); in client_init_dispatch()
2844 ssh_dispatch_set(ssh, SSH2_MSG_GLOBAL_REQUEST, &client_input_global_request); in client_init_dispatch()
2847 ssh_dispatch_set(ssh, SSH2_MSG_KEXINIT, &kex_input_kexinit); in client_init_dispatch()
2850 ssh_dispatch_set(ssh, SSH2_MSG_REQUEST_FAILURE, &client_global_request_reply); in client_init_dispatch()
2851 ssh_dispatch_set(ssh, SSH2_MSG_REQUEST_SUCCESS, &client_global_request_reply); in client_init_dispatch()