Lines Matching refs:ssh

164 static void client_init_dispatch(struct ssh *ssh);
244 set_control_persist_exit_time(struct ssh *ssh) in set_control_persist_exit_time() argument
250 } else if (channel_still_open(ssh)) { in set_control_persist_exit_time()
288 client_x11_get_proto(struct ssh *ssh, const char *display, in client_x11_get_proto() argument
383 channel_set_x11_refuse_time(ssh, in client_x11_get_proto()
459 client_check_window_change(struct ssh *ssh) in client_check_window_change() argument
465 channel_send_window_changes(ssh); in client_check_window_change()
469 client_global_request_reply(int type, u_int32_t seq, struct ssh *ssh) in client_global_request_reply() argument
476 gc->cb(ssh, type, seq, gc->ctx); in client_global_request_reply()
482 ssh_packet_set_alive_timeouts(ssh, 0); in client_global_request_reply()
494 server_alive_check(struct ssh *ssh) in server_alive_check() argument
498 if (ssh_packet_inc_alive_timeouts(ssh) > options.server_alive_count_max) { in server_alive_check()
502 if ((r = sshpkt_start(ssh, SSH2_MSG_GLOBAL_REQUEST)) != 0 || in server_alive_check()
503 (r = sshpkt_put_cstring(ssh, "keepalive@openssh.com")) != 0 || in server_alive_check()
504 (r = sshpkt_put_u8(ssh, 1)) != 0 || /* boolean: want reply */ in server_alive_check()
505 (r = sshpkt_send(ssh)) != 0) in server_alive_check()
514 send_chaff(struct ssh *ssh) in send_chaff() argument
518 if (ssh->kex == NULL || (ssh->kex->flags & KEX_HAS_PING) == 0) in send_chaff()
526 if ((r = sshpkt_start(ssh, SSH2_MSG_PING)) != 0 || in send_chaff()
527 (r = sshpkt_put_cstring(ssh, "PING!")) != 0 || in send_chaff()
528 (r = sshpkt_send(ssh)) != 0) in send_chaff()
575 obfuscate_keystroke_timing(struct ssh *ssh, struct timespec *timeout, in obfuscate_keystroke_timing() argument
591 if (!channel_tty_open(ssh) || quit_pending) { in obfuscate_keystroke_timing()
594 } else if (ssh_packet_is_rekeying(ssh)) { in obfuscate_keystroke_timing()
597 } else if (!ssh_packet_interactive_data_to_write(ssh) && in obfuscate_keystroke_timing()
598 ssh_packet_have_data_to_write(ssh)) { in obfuscate_keystroke_timing()
602 ssh_packet_have_data_to_write(ssh)) { in obfuscate_keystroke_timing()
610 !ssh_packet_have_data_to_write(ssh)) { in obfuscate_keystroke_timing()
612 if (send_chaff(ssh)) in obfuscate_keystroke_timing()
632 if (!active && ssh_packet_interactive_data_to_write(ssh) && in obfuscate_keystroke_timing()
633 channel_did_enqueue && ssh_packet_have_data_to_write(ssh)) { in obfuscate_keystroke_timing()
682 client_wait_until_can_do_something(struct ssh *ssh, struct pollfd **pfdp, in client_wait_until_can_do_something() argument
694 channel_prepare_poll(ssh, pfdp, npfd_allocp, npfd_activep, 2, &timeout); in client_wait_until_can_do_something()
699 if (session_closed && !channel_still_open(ssh) && in client_wait_until_can_do_something()
700 !ssh_packet_have_data_to_write(ssh)) { in client_wait_until_can_do_something()
707 oready = obfuscate_keystroke_timing(ssh, &timeout, channel_did_enqueue); in client_wait_until_can_do_something()
713 (*pfdp)[1].events = (oready && ssh_packet_have_data_to_write(ssh)) ? in client_wait_until_can_do_something()
721 set_control_persist_exit_time(ssh); in client_wait_until_can_do_something()
726 if (options.rekey_interval > 0 && !ssh_packet_is_rekeying(ssh)) { in client_wait_until_can_do_something()
728 ssh_packet_get_rekey_timeout(ssh)); in client_wait_until_can_do_something()
758 server_alive_check(ssh); in client_wait_until_can_do_something()
789 client_process_net_input(struct ssh *ssh) in client_process_net_input() argument
798 if ((r = ssh_packet_process_read(ssh, connection_in)) == 0) in client_process_net_input()
813 client_status_confirm(struct ssh *ssh, int type, Channel *c, void *ctx) in client_status_confirm() argument
867 mux_tty_alloc_failed(ssh, c); in client_status_confirm()
869 chan_read_failed(ssh, c); in client_status_confirm()
870 chan_write_failed(ssh, c); in client_status_confirm()
877 client_abandon_status_confirm(struct ssh *ssh, Channel *c, void *ctx) in client_abandon_status_confirm() argument
883 client_expect_confirm(struct ssh *ssh, int id, const char *request, in client_expect_confirm() argument
891 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, const char *buf, in client_simple_escape_filter() argument
1426 return process_escapes(ssh, c, c->input, c->output, c->extended, in client_simple_escape_filter()
1431 client_channel_closed(struct ssh *ssh, int id, int force, void *arg) in client_channel_closed() argument
1433 channel_cancel_cleanup(ssh, id); in client_channel_closed()
1445 client_loop(struct ssh *ssh, int have_pty, int escape_char_arg, in client_loop() argument
1500 connection_in = ssh_packet_get_connection_in(ssh); in client_loop()
1501 connection_out = ssh_packet_get_connection_out(ssh); in client_loop()
1505 client_init_dispatch(ssh); in client_loop()
1526 channel_register_filter(ssh, session_ident, in client_loop()
1532 channel_register_cleanup(ssh, session_ident, in client_loop()
1550 client_process_buffered_input_packets(ssh); in client_loop()
1552 if (session_closed && !channel_still_open(ssh)) in client_loop()
1555 if (ssh_packet_is_rekeying(ssh)) { in client_loop()
1560 if ((r = kex_start_rekex(ssh)) != 0) in client_loop()
1568 if (ssh_packet_not_very_much_data_to_write(ssh)) in client_loop()
1569 channel_did_enqueue = channel_output_poll(ssh); in client_loop()
1575 client_check_window_change(ssh); in client_loop()
1585 client_wait_until_can_do_something(ssh, &pfd, &npfd_alloc, in client_loop()
1595 channel_after_poll(ssh, pfd, npfd_active); in client_loop()
1599 client_process_net_input(ssh); in client_loop()
1605 if ((r = ssh_packet_check_rekey(ssh)) != 0) in client_loop()
1613 if ((r = ssh_packet_write_poll(ssh)) < 0) { in client_loop()
1614 sshpkt_fatal(ssh, r, in client_loop()
1646 if ((r = sshpkt_start(ssh, SSH2_MSG_DISCONNECT)) != 0 || in client_loop()
1647 (r = sshpkt_put_u32(ssh, SSH2_DISCONNECT_BY_APPLICATION)) != 0 || in client_loop()
1648 (r = sshpkt_put_cstring(ssh, "disconnected by user")) != 0 || in client_loop()
1649 (r = sshpkt_put_cstring(ssh, "")) != 0 || /* language tag */ in client_loop()
1650 (r = sshpkt_send(ssh)) != 0 || in client_loop()
1651 (r = ssh_packet_write_wait(ssh)) < 0) in client_loop()
1654 channel_free_all(ssh); in client_loop()
1677 ssh_packet_get_bytes(ssh, &ibytes, &obytes); in client_loop()
1691 client_request_forwarded_tcpip(struct ssh *ssh, const char *request_type, in client_request_forwarded_tcpip() argument
1701 if ((r = sshpkt_get_cstring(ssh, &listen_address, NULL)) != 0 || in client_request_forwarded_tcpip()
1702 (r = sshpkt_get_u32(ssh, &listen_port)) != 0 || in client_request_forwarded_tcpip()
1703 (r = sshpkt_get_cstring(ssh, &originator_address, NULL)) != 0 || in client_request_forwarded_tcpip()
1704 (r = sshpkt_get_u32(ssh, &originator_port)) != 0 || in client_request_forwarded_tcpip()
1705 (r = sshpkt_get_end(ssh)) != 0) in client_request_forwarded_tcpip()
1716 c = channel_connect_by_listen_address(ssh, in client_request_forwarded_tcpip()
1751 client_request_forwarded_streamlocal(struct ssh *ssh, in client_request_forwarded_streamlocal() argument
1759 if ((r = sshpkt_get_cstring(ssh, &listen_path, NULL)) != 0 || in client_request_forwarded_streamlocal()
1760 (r = sshpkt_get_string(ssh, NULL, NULL)) != 0 || /* reserved */ in client_request_forwarded_streamlocal()
1761 (r = sshpkt_get_end(ssh)) != 0) in client_request_forwarded_streamlocal()
1766 c = channel_connect_by_listen_path(ssh, listen_path, in client_request_forwarded_streamlocal()
1773 client_request_x11(struct ssh *ssh, const char *request_type, int rchan) in client_request_x11() argument
1791 if ((r = sshpkt_get_cstring(ssh, &originator, NULL)) != 0 || in client_request_x11()
1792 (r = sshpkt_get_u32(ssh, &originator_port)) != 0 || in client_request_x11()
1793 (r = sshpkt_get_end(ssh)) != 0) in client_request_x11()
1800 sock = x11_connect_display(ssh); in client_request_x11()
1805 c = channel_new(ssh, "x11-connection", in client_request_x11()
1809 c = channel_new(ssh, "x11-connection", in client_request_x11()
1817 client_request_agent(struct ssh *ssh, const char *request_type, int rchan) in client_request_agent() argument
1838 if ((r = ssh_agent_bind_hostkey(sock, ssh->kex->initial_hostkey, in client_request_agent()
1839 ssh->kex->session_id, ssh->kex->initial_sig, 1)) == 0) in client_request_agent()
1845 c = channel_new(ssh, "agent-connection", in client_request_agent()
1850 c = channel_new(ssh, "agent connection", in client_request_agent()
1859 client_request_tun_fwd(struct ssh *ssh, int tun_mode, in client_request_tun_fwd() argument
1879 c = channel_new(ssh, "tun-connection", SSH_CHANNEL_OPENING, fd, fd, -1, in client_request_tun_fwd()
1882 c = channel_new(ssh, "tun-connection", SSH_CHANNEL_OPENING, fd, fd, -1, in client_request_tun_fwd()
1887 channel_register_open_confirm(ssh, c->self, cb, cbctx); in client_request_tun_fwd()
1889 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN)) != 0 || in client_request_tun_fwd()
1890 (r = sshpkt_put_cstring(ssh, "tun@openssh.com")) != 0 || in client_request_tun_fwd()
1891 (r = sshpkt_put_u32(ssh, c->self)) != 0 || in client_request_tun_fwd()
1892 (r = sshpkt_put_u32(ssh, c->local_window_max)) != 0 || in client_request_tun_fwd()
1893 (r = sshpkt_put_u32(ssh, c->local_maxpacket)) != 0 || in client_request_tun_fwd()
1894 (r = sshpkt_put_u32(ssh, tun_mode)) != 0 || in client_request_tun_fwd()
1895 (r = sshpkt_put_u32(ssh, remote_tun)) != 0 || in client_request_tun_fwd()
1896 (r = sshpkt_send(ssh)) != 0) in client_request_tun_fwd()
1897 sshpkt_fatal(ssh, r, "%s: send reply", __func__); in client_request_tun_fwd()
1904 client_input_channel_open(int type, u_int32_t seq, struct ssh *ssh) in client_input_channel_open() argument
1913 if ((r = sshpkt_get_cstring(ssh, &ctype, &len)) != 0 || in client_input_channel_open()
1914 (r = sshpkt_get_u32(ssh, &rchan)) != 0 || in client_input_channel_open()
1915 (r = sshpkt_get_u32(ssh, &rwindow)) != 0 || in client_input_channel_open()
1916 (r = sshpkt_get_u32(ssh, &rmaxpack)) != 0) in client_input_channel_open()
1923 c = client_request_forwarded_tcpip(ssh, ctype, rchan, rwindow, in client_input_channel_open()
1926 c = client_request_forwarded_streamlocal(ssh, ctype, rchan); in client_input_channel_open()
1928 c = client_request_x11(ssh, ctype, rchan); in client_input_channel_open()
1930 c = client_request_agent(ssh, ctype, rchan); in client_input_channel_open()
1941 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION)) != 0 || in client_input_channel_open()
1942 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in client_input_channel_open()
1943 (r = sshpkt_put_u32(ssh, c->self)) != 0 || in client_input_channel_open()
1944 (r = sshpkt_put_u32(ssh, c->local_window)) != 0 || in client_input_channel_open()
1945 (r = sshpkt_put_u32(ssh, c->local_maxpacket)) != 0 || in client_input_channel_open()
1946 (r = sshpkt_send(ssh)) != 0) in client_input_channel_open()
1947 sshpkt_fatal(ssh, r, "%s: send reply", __func__); in client_input_channel_open()
1951 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN_FAILURE)) != 0 || in client_input_channel_open()
1952 (r = sshpkt_put_u32(ssh, rchan)) != 0 || in client_input_channel_open()
1953 (r = sshpkt_put_u32(ssh, SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED)) != 0 || in client_input_channel_open()
1954 (r = sshpkt_put_cstring(ssh, "open failed")) != 0 || in client_input_channel_open()
1955 (r = sshpkt_put_cstring(ssh, "")) != 0 || in client_input_channel_open()
1956 (r = sshpkt_send(ssh)) != 0) in client_input_channel_open()
1957 sshpkt_fatal(ssh, r, "%s: send failure", __func__); in client_input_channel_open()
1966 client_input_channel_req(int type, u_int32_t seq, struct ssh *ssh) in client_input_channel_req() argument
1974 if ((r = sshpkt_get_u32(ssh, &id)) != 0) in client_input_channel_req()
1977 c = channel_lookup(ssh, id); in client_input_channel_req()
1978 if (channel_proxy_upstream(c, type, seq, ssh)) in client_input_channel_req()
1980 if ((r = sshpkt_get_cstring(ssh, &rtype, NULL)) != 0 || in client_input_channel_req()
1981 (r = sshpkt_get_u8(ssh, &reply)) != 0) in client_input_channel_req()
1991 if ((r = sshpkt_get_end(ssh)) != 0) in client_input_channel_req()
1993 chan_rcvd_eow(ssh, c); in client_input_channel_req()
1995 if ((r = sshpkt_get_u32(ssh, &exitval)) != 0) in client_input_channel_req()
1998 mux_exit_message(ssh, c, exitval); in client_input_channel_req()
2009 if ((r = sshpkt_get_end(ssh)) != 0) in client_input_channel_req()
2015 if ((r = sshpkt_start(ssh, success ? in client_input_channel_req()
2017 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in client_input_channel_req()
2018 (r = sshpkt_send(ssh)) != 0) in client_input_channel_req()
2019 sshpkt_fatal(ssh, r, "%s: send failure", __func__); in client_input_channel_req()
2343 client_global_hostkeys_prove_confirm(struct ssh *ssh, int type, in client_global_hostkeys_prove_confirm() argument
2364 ssh->kex->hostkey_alg)) == KEY_RSA) in client_global_hostkeys_prove_confirm()
2365 rsa_kexalg = ssh->kex->hostkey_alg; in client_global_hostkeys_prove_confirm()
2382 ssh->kex->session_id)) != 0 || in client_global_hostkeys_prove_confirm()
2386 if ((r = sshpkt_get_string_direct(ssh, &sig, &siglen)) != 0) { in client_global_hostkeys_prove_confirm()
2428 if ((r = sshpkt_get_end(ssh)) != 0) { in client_global_hostkeys_prove_confirm()
2447 client_input_hostkeys(struct ssh *ssh) in client_input_hostkeys() argument
2467 while (ssh_packet_remaining(ssh) > 0) { in client_input_hostkeys()
2470 if ((r = sshpkt_get_string_direct(ssh, &blob, &len)) != 0) { in client_input_hostkeys()
2613 if ((r = sshpkt_start(ssh, SSH2_MSG_GLOBAL_REQUEST)) != 0 || in client_input_hostkeys()
2614 (r = sshpkt_put_cstring(ssh, in client_input_hostkeys()
2616 (r = sshpkt_put_u8(ssh, 1)) != 0) /* bool: want reply */ in client_input_hostkeys()
2625 (r = sshpkt_put_stringb(ssh, buf)) != 0) in client_input_hostkeys()
2628 if ((r = sshpkt_send(ssh)) != 0) in client_input_hostkeys()
2653 client_input_global_request(int type, u_int32_t seq, struct ssh *ssh) in client_input_global_request() argument
2659 if ((r = sshpkt_get_cstring(ssh, &rtype, NULL)) != 0 || in client_input_global_request()
2660 (r = sshpkt_get_u8(ssh, &want_reply)) != 0) in client_input_global_request()
2665 success = client_input_hostkeys(ssh); in client_input_global_request()
2667 if ((r = sshpkt_start(ssh, success ? SSH2_MSG_REQUEST_SUCCESS : in client_input_global_request()
2669 (r = sshpkt_send(ssh)) != 0 || in client_input_global_request()
2670 (r = ssh_packet_write_wait(ssh)) != 0) in client_input_global_request()
2680 client_send_env(struct ssh *ssh, int id, const char *name, const char *val) in client_send_env() argument
2685 channel_request_start(ssh, id, "env", 0); in client_send_env()
2686 if ((r = sshpkt_put_cstring(ssh, name)) != 0 || in client_send_env()
2687 (r = sshpkt_put_cstring(ssh, val)) != 0 || in client_send_env()
2688 (r = sshpkt_send(ssh)) != 0) in client_send_env()
2693 client_session2_setup(struct ssh *ssh, int id, int want_tty, int want_subsystem, in client_session2_setup() argument
2704 if ((c = channel_lookup(ssh, id)) == NULL) in client_session2_setup()
2707 ssh_packet_set_interactive(ssh, want_tty, in client_session2_setup()
2717 channel_request_start(ssh, id, "pty-req", 1); in client_session2_setup()
2718 client_expect_confirm(ssh, id, "PTY allocation", CONFIRM_TTY); in client_session2_setup()
2719 if ((r = sshpkt_put_cstring(ssh, term != NULL ? term : "")) in client_session2_setup()
2721 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_col)) != 0 || in client_session2_setup()
2722 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_row)) != 0 || in client_session2_setup()
2723 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_xpixel)) != 0 || in client_session2_setup()
2724 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_ypixel)) != 0) in client_session2_setup()
2728 ssh_tty_make_modes(ssh, -1, tiop); in client_session2_setup()
2729 if ((r = sshpkt_send(ssh)) != 0) in client_session2_setup()
2759 client_send_env(ssh, id, name, val); in client_session2_setup()
2771 client_send_env(ssh, id, name, val); in client_session2_setup()
2782 channel_request_start(ssh, id, "subsystem", 1); in client_session2_setup()
2783 client_expect_confirm(ssh, id, "subsystem", in client_session2_setup()
2788 channel_request_start(ssh, id, "exec", 1); in client_session2_setup()
2789 client_expect_confirm(ssh, id, "exec", CONFIRM_CLOSE); in client_session2_setup()
2791 if ((r = sshpkt_put_stringb(ssh, cmd)) != 0 || in client_session2_setup()
2792 (r = sshpkt_send(ssh)) != 0) in client_session2_setup()
2795 channel_request_start(ssh, id, "shell", 1); in client_session2_setup()
2796 client_expect_confirm(ssh, id, "shell", CONFIRM_CLOSE); in client_session2_setup()
2797 if ((r = sshpkt_send(ssh)) != 0) in client_session2_setup()
2806 client_init_dispatch(struct ssh *ssh) in client_init_dispatch() argument
2808 ssh_dispatch_init(ssh, &dispatch_protocol_error); in client_init_dispatch()
2810 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_CLOSE, &channel_input_oclose); in client_init_dispatch()
2811 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_DATA, &channel_input_data); in client_init_dispatch()
2812 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_EOF, &channel_input_ieof); in client_init_dispatch()
2813 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_EXTENDED_DATA, &channel_input_extended_data); in client_init_dispatch()
2814 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_OPEN, &client_input_channel_open); in client_init_dispatch()
2815 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, &channel_input_open_confirmation); in client_init_dispatch()
2816 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure); in client_init_dispatch()
2817 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_REQUEST, &client_input_channel_req); in client_init_dispatch()
2818 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust); in client_init_dispatch()
2819 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_SUCCESS, &channel_input_status_confirm); in client_init_dispatch()
2820 ssh_dispatch_set(ssh, SSH2_MSG_CHANNEL_FAILURE, &channel_input_status_confirm); in client_init_dispatch()
2821 ssh_dispatch_set(ssh, SSH2_MSG_GLOBAL_REQUEST, &client_input_global_request); in client_init_dispatch()
2824 ssh_dispatch_set(ssh, SSH2_MSG_KEXINIT, &kex_input_kexinit); in client_init_dispatch()
2827 ssh_dispatch_set(ssh, SSH2_MSG_REQUEST_FAILURE, &client_global_request_reply); in client_init_dispatch()
2828 ssh_dispatch_set(ssh, SSH2_MSG_REQUEST_SUCCESS, &client_global_request_reply); in client_init_dispatch()