Lines Matching refs:ssh
168 static void client_init_dispatch(struct ssh *ssh);
245 set_control_persist_exit_time(struct ssh *ssh) in set_control_persist_exit_time() argument
251 } else if (channel_still_open(ssh)) { in set_control_persist_exit_time()
289 client_x11_get_proto(struct ssh *ssh, const char *display, in client_x11_get_proto() argument
384 channel_set_x11_refuse_time(ssh, in client_x11_get_proto()
460 client_check_window_change(struct ssh *ssh) in client_check_window_change() argument
466 channel_send_window_changes(ssh); in client_check_window_change()
470 client_global_request_reply(int type, u_int32_t seq, struct ssh *ssh) in client_global_request_reply() argument
477 gc->cb(ssh, type, seq, gc->ctx); in client_global_request_reply()
483 ssh_packet_set_alive_timeouts(ssh, 0); in client_global_request_reply()
495 server_alive_check(struct ssh *ssh) in server_alive_check() argument
499 if (ssh_packet_inc_alive_timeouts(ssh) > options.server_alive_count_max) { in server_alive_check()
503 if ((r = sshpkt_start(ssh, SSH2_MSG_GLOBAL_REQUEST)) != 0 || in server_alive_check()
504 (r = sshpkt_put_cstring(ssh, "keepalive@openssh.com")) != 0 || in server_alive_check()
505 (r = sshpkt_put_u8(ssh, 1)) != 0 || /* boolean: want reply */ in server_alive_check()
506 (r = sshpkt_send(ssh)) != 0) in server_alive_check()
515 send_chaff(struct ssh *ssh) in send_chaff() argument
519 if (ssh->kex == NULL || (ssh->kex->flags & KEX_HAS_PING) == 0) in send_chaff()
527 if ((r = sshpkt_start(ssh, SSH2_MSG_PING)) != 0 || in send_chaff()
528 (r = sshpkt_put_cstring(ssh, "PING!")) != 0 || in send_chaff()
529 (r = sshpkt_send(ssh)) != 0) in send_chaff()
576 obfuscate_keystroke_timing(struct ssh *ssh, struct timespec *timeout, in obfuscate_keystroke_timing() argument
592 if (!channel_tty_open(ssh) || quit_pending) { in obfuscate_keystroke_timing()
595 } else if (ssh_packet_is_rekeying(ssh)) { in obfuscate_keystroke_timing()
598 } else if (!ssh_packet_interactive_data_to_write(ssh) && in obfuscate_keystroke_timing()
599 ssh_packet_have_data_to_write(ssh)) { in obfuscate_keystroke_timing()
603 ssh_packet_have_data_to_write(ssh)) { in obfuscate_keystroke_timing()
611 !ssh_packet_have_data_to_write(ssh)) { in obfuscate_keystroke_timing()
613 if (send_chaff(ssh)) in obfuscate_keystroke_timing()
633 if (!active && ssh_packet_interactive_data_to_write(ssh) && in obfuscate_keystroke_timing()
634 channel_did_enqueue && ssh_packet_have_data_to_write(ssh)) { in obfuscate_keystroke_timing()
683 client_wait_until_can_do_something(struct ssh *ssh, struct pollfd **pfdp, in client_wait_until_can_do_something() argument
695 channel_prepare_poll(ssh, pfdp, npfd_allocp, npfd_activep, 2, &timeout); in client_wait_until_can_do_something()
700 if (session_closed && !channel_still_open(ssh) && in client_wait_until_can_do_something()
701 !ssh_packet_have_data_to_write(ssh)) { in client_wait_until_can_do_something()
708 oready = obfuscate_keystroke_timing(ssh, &timeout, channel_did_enqueue); in client_wait_until_can_do_something()
714 (*pfdp)[1].events = (oready && ssh_packet_have_data_to_write(ssh)) ? in client_wait_until_can_do_something()
722 set_control_persist_exit_time(ssh); in client_wait_until_can_do_something()
727 if (options.rekey_interval > 0 && !ssh_packet_is_rekeying(ssh)) { in client_wait_until_can_do_something()
729 ssh_packet_get_rekey_timeout(ssh)); in client_wait_until_can_do_something()
759 server_alive_check(ssh); in client_wait_until_can_do_something()
790 client_process_net_input(struct ssh *ssh) in client_process_net_input() argument
799 if ((r = ssh_packet_process_read(ssh, connection_in)) == 0) in client_process_net_input()
814 client_status_confirm(struct ssh *ssh, int type, Channel *c, void *ctx) in client_status_confirm() argument
868 mux_tty_alloc_failed(ssh, c); in client_status_confirm()
870 chan_read_failed(ssh, c); in client_status_confirm()
871 chan_write_failed(ssh, c); in client_status_confirm()
878 client_abandon_status_confirm(struct ssh *ssh, Channel *c, void *ctx) in client_abandon_status_confirm() argument
884 client_expect_confirm(struct ssh *ssh, int id, const char *request, in client_expect_confirm() argument
892 channel_register_status_confirm(ssh, id, client_status_confirm, in client_expect_confirm()
984 process_cmdline(struct ssh *ssh) in process_cmdline() argument
1058 ok = channel_request_rforward_cancel(ssh, &fwd) == 0; in process_cmdline()
1060 ok = channel_cancel_lport_listener(ssh, &fwd, in process_cmdline()
1063 ok = channel_cancel_lport_listener(ssh, &fwd, in process_cmdline()
1084 if (!channel_setup_local_fwd_listener(ssh, &fwd, in process_cmdline()
1090 if (channel_request_remote_forwarding(ssh, &fwd) < 0) { in process_cmdline()
1170 process_escapes(struct ssh *ssh, Channel *c, in process_escapes() argument
1203 channel_force_close(ssh, c, 1); in process_escapes()
1241 channel_request_start(ssh, c->self, "break", 0); in process_escapes()
1242 if ((r = sshpkt_put_u32(ssh, 1000)) != 0 || in process_escapes()
1243 (r = sshpkt_send(ssh)) != 0) in process_escapes()
1248 if (ssh->compat & SSH_BUG_NOREKEY) in process_escapes()
1293 channel_stop_listening(ssh); in process_escapes()
1324 s = channel_open_message(ssh); in process_escapes()
1339 process_cmdline(ssh); in process_escapes()
1392 client_process_buffered_input_packets(struct ssh *ssh) in client_process_buffered_input_packets() argument
1394 ssh_dispatch_run_fatal(ssh, DISPATCH_NONBLOCK, &quit_pending); in client_process_buffered_input_packets()
1413 client_filter_cleanup(struct ssh *ssh, int cid, void *ctx) in client_filter_cleanup() argument
1419 client_simple_escape_filter(struct ssh *ssh, Channel *c, char *buf, int len) in client_simple_escape_filter() argument
1424 return process_escapes(ssh, c, c->input, c->output, c->extended, in client_simple_escape_filter()
1429 client_channel_closed(struct ssh *ssh, int id, int force, void *arg) in client_channel_closed() argument
1431 channel_cancel_cleanup(ssh, id); in client_channel_closed()
1443 client_loop(struct ssh *ssh, int have_pty, int escape_char_arg, in client_loop() argument
1496 connection_in = ssh_packet_get_connection_in(ssh); in client_loop()
1497 connection_out = ssh_packet_get_connection_out(ssh); in client_loop()
1501 client_init_dispatch(ssh); in client_loop()
1522 channel_register_filter(ssh, session_ident, in client_loop()
1528 channel_register_cleanup(ssh, session_ident, in client_loop()
1546 client_process_buffered_input_packets(ssh); in client_loop()
1548 if (session_closed && !channel_still_open(ssh)) in client_loop()
1551 if (ssh_packet_is_rekeying(ssh)) { in client_loop()
1556 if ((r = kex_start_rekex(ssh)) != 0) in client_loop()
1564 if (ssh_packet_not_very_much_data_to_write(ssh)) in client_loop()
1565 channel_did_enqueue = channel_output_poll(ssh); in client_loop()
1571 client_check_window_change(ssh); in client_loop()
1581 client_wait_until_can_do_something(ssh, &pfd, &npfd_alloc, in client_loop()
1591 channel_after_poll(ssh, pfd, npfd_active); in client_loop()
1595 client_process_net_input(ssh); in client_loop()
1601 if ((r = ssh_packet_check_rekey(ssh)) != 0) in client_loop()
1609 if ((r = ssh_packet_write_poll(ssh)) != 0) { in client_loop()
1610 sshpkt_fatal(ssh, r, in client_loop()
1642 if ((r = sshpkt_start(ssh, SSH2_MSG_DISCONNECT)) != 0 || in client_loop()
1643 (r = sshpkt_put_u32(ssh, SSH2_DISCONNECT_BY_APPLICATION)) != 0 || in client_loop()
1644 (r = sshpkt_put_cstring(ssh, "disconnected by user")) != 0 || in client_loop()
1645 (r = sshpkt_put_cstring(ssh, "")) != 0 || /* language tag */ in client_loop()
1646 (r = sshpkt_send(ssh)) != 0 || in client_loop()
1647 (r = ssh_packet_write_wait(ssh)) != 0) in client_loop()
1650 channel_free_all(ssh); in client_loop()
1673 ssh_packet_get_bytes(ssh, &ibytes, &obytes); in client_loop()
1687 client_request_forwarded_tcpip(struct ssh *ssh, const char *request_type, in client_request_forwarded_tcpip() argument
1697 if ((r = sshpkt_get_cstring(ssh, &listen_address, NULL)) != 0 || in client_request_forwarded_tcpip()
1698 (r = sshpkt_get_u32(ssh, &listen_port)) != 0 || in client_request_forwarded_tcpip()
1699 (r = sshpkt_get_cstring(ssh, &originator_address, NULL)) != 0 || in client_request_forwarded_tcpip()
1700 (r = sshpkt_get_u32(ssh, &originator_port)) != 0 || in client_request_forwarded_tcpip()
1701 (r = sshpkt_get_end(ssh)) != 0) in client_request_forwarded_tcpip()
1712 c = channel_connect_by_listen_address(ssh, in client_request_forwarded_tcpip()
1747 client_request_forwarded_streamlocal(struct ssh *ssh, in client_request_forwarded_streamlocal() argument
1755 if ((r = sshpkt_get_cstring(ssh, &listen_path, NULL)) != 0 || in client_request_forwarded_streamlocal()
1756 (r = sshpkt_get_string(ssh, NULL, NULL)) != 0 || /* reserved */ in client_request_forwarded_streamlocal()
1757 (r = sshpkt_get_end(ssh)) != 0) in client_request_forwarded_streamlocal()
1762 c = channel_connect_by_listen_path(ssh, listen_path, in client_request_forwarded_streamlocal()
1769 client_request_x11(struct ssh *ssh, const char *request_type, int rchan) in client_request_x11() argument
1787 if ((r = sshpkt_get_cstring(ssh, &originator, NULL)) != 0 || in client_request_x11()
1788 (r = sshpkt_get_u32(ssh, &originator_port)) != 0 || in client_request_x11()
1789 (r = sshpkt_get_end(ssh)) != 0) in client_request_x11()
1796 sock = x11_connect_display(ssh); in client_request_x11()
1799 c = channel_new(ssh, "x11-connection", in client_request_x11()
1807 client_request_agent(struct ssh *ssh, const char *request_type, int rchan) in client_request_agent() argument
1828 if ((r = ssh_agent_bind_hostkey(sock, ssh->kex->initial_hostkey, in client_request_agent()
1829 ssh->kex->session_id, ssh->kex->initial_sig, 1)) == 0) in client_request_agent()
1834 c = channel_new(ssh, "agent-connection", in client_request_agent()
1843 client_request_tun_fwd(struct ssh *ssh, int tun_mode, in client_request_tun_fwd() argument
1862 c = channel_new(ssh, "tun-connection", SSH_CHANNEL_OPENING, fd, fd, -1, in client_request_tun_fwd()
1868 channel_register_filter(ssh, c->self, sys_tun_infilter, in client_request_tun_fwd()
1873 channel_register_open_confirm(ssh, c->self, cb, cbctx); in client_request_tun_fwd()
1875 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN)) != 0 || in client_request_tun_fwd()
1876 (r = sshpkt_put_cstring(ssh, "tun@openssh.com")) != 0 || in client_request_tun_fwd()
1877 (r = sshpkt_put_u32(ssh, c->self)) != 0 || in client_request_tun_fwd()
1878 (r = sshpkt_put_u32(ssh, c->local_window_max)) != 0 || in client_request_tun_fwd()
1879 (r = sshpkt_put_u32(ssh, c->local_maxpacket)) != 0 || in client_request_tun_fwd()
1880 (r = sshpkt_put_u32(ssh, tun_mode)) != 0 || in client_request_tun_fwd()
1881 (r = sshpkt_put_u32(ssh, remote_tun)) != 0 || in client_request_tun_fwd()
1882 (r = sshpkt_send(ssh)) != 0) in client_request_tun_fwd()
1883 sshpkt_fatal(ssh, r, "%s: send reply", __func__); in client_request_tun_fwd()
1890 client_input_channel_open(int type, u_int32_t seq, struct ssh *ssh) in client_input_channel_open() argument
1899 if ((r = sshpkt_get_cstring(ssh, &ctype, &len)) != 0 || in client_input_channel_open()
1900 (r = sshpkt_get_u32(ssh, &rchan)) != 0 || in client_input_channel_open()
1901 (r = sshpkt_get_u32(ssh, &rwindow)) != 0 || in client_input_channel_open()
1902 (r = sshpkt_get_u32(ssh, &rmaxpack)) != 0) in client_input_channel_open()
1909 c = client_request_forwarded_tcpip(ssh, ctype, rchan, rwindow, in client_input_channel_open()
1912 c = client_request_forwarded_streamlocal(ssh, ctype, rchan); in client_input_channel_open()
1914 c = client_request_x11(ssh, ctype, rchan); in client_input_channel_open()
1916 c = client_request_agent(ssh, ctype, rchan); in client_input_channel_open()
1927 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION)) != 0 || in client_input_channel_open()
1928 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in client_input_channel_open()
1929 (r = sshpkt_put_u32(ssh, c->self)) != 0 || in client_input_channel_open()
1930 (r = sshpkt_put_u32(ssh, c->local_window)) != 0 || in client_input_channel_open()
1931 (r = sshpkt_put_u32(ssh, c->local_maxpacket)) != 0 || in client_input_channel_open()
1932 (r = sshpkt_send(ssh)) != 0) in client_input_channel_open()
1933 sshpkt_fatal(ssh, r, "%s: send reply", __func__); in client_input_channel_open()
1937 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN_FAILURE)) != 0 || in client_input_channel_open()
1938 (r = sshpkt_put_u32(ssh, rchan)) != 0 || in client_input_channel_open()
1939 (r = sshpkt_put_u32(ssh, SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED)) != 0 || in client_input_channel_open()
1940 (r = sshpkt_put_cstring(ssh, "open failed")) != 0 || in client_input_channel_open()
1941 (r = sshpkt_put_cstring(ssh, "")) != 0 || in client_input_channel_open()
1942 (r = sshpkt_send(ssh)) != 0) in client_input_channel_open()
1943 sshpkt_fatal(ssh, r, "%s: send failure", __func__); in client_input_channel_open()
1952 client_input_channel_req(int type, u_int32_t seq, struct ssh *ssh) in client_input_channel_req() argument
1960 if ((r = sshpkt_get_u32(ssh, &id)) != 0) in client_input_channel_req()
1963 c = channel_lookup(ssh, id); in client_input_channel_req()
1964 if (channel_proxy_upstream(c, type, seq, ssh)) in client_input_channel_req()
1966 if ((r = sshpkt_get_cstring(ssh, &rtype, NULL)) != 0 || in client_input_channel_req()
1967 (r = sshpkt_get_u8(ssh, &reply)) != 0) in client_input_channel_req()
1977 if ((r = sshpkt_get_end(ssh)) != 0) in client_input_channel_req()
1979 chan_rcvd_eow(ssh, c); in client_input_channel_req()
1981 if ((r = sshpkt_get_u32(ssh, &exitval)) != 0) in client_input_channel_req()
1984 mux_exit_message(ssh, c, exitval); in client_input_channel_req()
1995 if ((r = sshpkt_get_end(ssh)) != 0) in client_input_channel_req()
2001 if ((r = sshpkt_start(ssh, success ? in client_input_channel_req()
2003 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in client_input_channel_req()
2004 (r = sshpkt_send(ssh)) != 0) in client_input_channel_req()
2005 sshpkt_fatal(ssh, r, "%s: send failure", __func__); in client_input_channel_req()
2329 client_global_hostkeys_prove_confirm(struct ssh *ssh, int type, in client_global_hostkeys_prove_confirm() argument
2350 ssh->kex->hostkey_alg)) == KEY_RSA) in client_global_hostkeys_prove_confirm()
2351 rsa_kexalg = ssh->kex->hostkey_alg; in client_global_hostkeys_prove_confirm()
2368 ssh->kex->session_id)) != 0 || in client_global_hostkeys_prove_confirm()
2372 if ((r = sshpkt_get_string_direct(ssh, &sig, &siglen)) != 0) { in client_global_hostkeys_prove_confirm()
2414 if ((r = sshpkt_get_end(ssh)) != 0) { in client_global_hostkeys_prove_confirm()
2433 client_input_hostkeys(struct ssh *ssh) in client_input_hostkeys() argument
2453 while (ssh_packet_remaining(ssh) > 0) { in client_input_hostkeys()
2456 if ((r = sshpkt_get_string_direct(ssh, &blob, &len)) != 0) { in client_input_hostkeys()
2599 if ((r = sshpkt_start(ssh, SSH2_MSG_GLOBAL_REQUEST)) != 0 || in client_input_hostkeys()
2600 (r = sshpkt_put_cstring(ssh, in client_input_hostkeys()
2602 (r = sshpkt_put_u8(ssh, 1)) != 0) /* bool: want reply */ in client_input_hostkeys()
2611 (r = sshpkt_put_stringb(ssh, buf)) != 0) in client_input_hostkeys()
2614 if ((r = sshpkt_send(ssh)) != 0) in client_input_hostkeys()
2639 client_input_global_request(int type, u_int32_t seq, struct ssh *ssh) in client_input_global_request() argument
2645 if ((r = sshpkt_get_cstring(ssh, &rtype, NULL)) != 0 || in client_input_global_request()
2646 (r = sshpkt_get_u8(ssh, &want_reply)) != 0) in client_input_global_request()
2651 success = client_input_hostkeys(ssh); in client_input_global_request()
2653 if ((r = sshpkt_start(ssh, success ? SSH2_MSG_REQUEST_SUCCESS : in client_input_global_request()
2655 (r = sshpkt_send(ssh)) != 0 || in client_input_global_request()
2656 (r = ssh_packet_write_wait(ssh)) != 0) in client_input_global_request()
2666 client_send_env(struct ssh *ssh, int id, const char *name, const char *val) in client_send_env() argument
2671 channel_request_start(ssh, id, "env", 0); in client_send_env()
2672 if ((r = sshpkt_put_cstring(ssh, name)) != 0 || in client_send_env()
2673 (r = sshpkt_put_cstring(ssh, val)) != 0 || in client_send_env()
2674 (r = sshpkt_send(ssh)) != 0) in client_send_env()
2679 client_session2_setup(struct ssh *ssh, int id, int want_tty, int want_subsystem, in client_session2_setup() argument
2690 if ((c = channel_lookup(ssh, id)) == NULL) in client_session2_setup()
2693 ssh_packet_set_interactive(ssh, want_tty, in client_session2_setup()
2703 channel_request_start(ssh, id, "pty-req", 1); in client_session2_setup()
2704 client_expect_confirm(ssh, id, "PTY allocation", CONFIRM_TTY); in client_session2_setup()
2705 if ((r = sshpkt_put_cstring(ssh, term != NULL ? term : "")) in client_session2_setup()
2707 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_col)) != 0 || in client_session2_setup()
2708 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_row)) != 0 || in client_session2_setup()
2709 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_xpixel)) != 0 || in client_session2_setup()
2710 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_ypixel)) != 0) in client_session2_setup()
2714 ssh_tty_make_modes(ssh, -1, tiop); in client_session2_setup()
2715 if ((r = sshpkt_send(ssh)) != 0) in client_session2_setup()
2745 client_send_env(ssh, id, name, val); in client_session2_setup()
2757 client_send_env(ssh, id, name, val); in client_session2_setup()
2768 channel_request_start(ssh, id, "subsystem", 1); in client_session2_setup()
2769 client_expect_confirm(ssh, id, "subsystem", in client_session2_setup()
2774 channel_request_start(ssh, id, "exec", 1); in client_session2_setup()
2775 client_expect_confirm(ssh, id, "exec", CONFIRM_CLOSE); in client_session2_setup()
2777 if ((r = sshpkt_put_stringb(ssh, cmd)) != 0 || in client_session2_setup()
2778 (r = sshpkt_send(ssh)) != 0) in client_session2_setup()
2781 channel_request_start(ssh, id, "shell", 1); in client_session2_setup()
2782 client_expect_confirm(ssh, id, "shell", CONFIRM_CLOSE); in client_session2_setup()
2783 if ((r = sshpkt_send(ssh)) != 0) in client_session2_setup()
2792 client_init_dispatch(struct ssh *ssh) in client_init_dispatch() argument
2794 ssh_dispatch_init(ssh, &dispatch_protocol_error); in client_init_dispatch()
2796 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_CLOSE, &channel_input_oclose); in client_init_dispatch()
2797 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_DATA, &channel_input_data); in client_init_dispatch()
2798 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_EOF, &channel_input_ieof); in client_init_dispatch()
2799 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_EXTENDED_DATA, &channel_input_extended_data); in client_init_dispatch()
2800 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_OPEN, &client_input_channel_open); in client_init_dispatch()
2801 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, &channel_input_open_confirmation); in client_init_dispatch()
2802 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure); in client_init_dispatch()
2803 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_REQUEST, &client_input_channel_req); in client_init_dispatch()
2804 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust); in client_init_dispatch()
2805 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_SUCCESS, &channel_input_status_confirm); in client_init_dispatch()
2806 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_FAILURE, &channel_input_status_confirm); in client_init_dispatch()
2807 ssh_dispatch_set(ssh, SSH2_MSG_GLOBAL_REQUEST, &client_input_global_request); in client_init_dispatch()
2810 ssh_dispatch_set(ssh, SSH2_MSG_KEXINIT, &kex_input_kexinit); in client_init_dispatch()
2813 ssh_dispatch_set(ssh, SSH2_MSG_REQUEST_FAILURE, &client_global_request_reply); in client_init_dispatch()
2814 ssh_dispatch_set(ssh, SSH2_MSG_REQUEST_SUCCESS, &client_global_request_reply); in client_init_dispatch()