Lines Matching defs:ssh
10 * called by a name other than "ssh" or "Secure Shell".
60 #include "ssh.h"
85 #include "ssh-gss.h"
104 void session_set_fds(struct ssh *, Session *, int, int, int, int, int);
107 int session_setup_x11fwd(struct ssh *, Session *);
108 int do_exec_pty(struct ssh *, Session *, const char *);
109 int do_exec_no_pty(struct ssh *, Session *, const char *);
110 int do_exec(struct ssh *, Session *, const char *);
111 void do_login(struct ssh *, Session *, const char *);
112 void do_child(struct ssh *, Session *, const char *);
116 static void do_authenticated2(struct ssh *, Authctxt *);
118 static int session_pty_req(struct ssh *, Session *);
171 auth_input_request_forwarding(struct ssh *ssh, struct passwd * pw)
185 auth_sock_dir = xstrdup("/tmp/ssh-XXXXXXXXXX");
189 ssh_packet_send_debug(ssh, "Agent forwarding disabled: "
211 nc = channel_new(ssh, "auth-listener",
281 set_fwdpermit_from_authopts(struct ssh *ssh, const struct sshauthopt *opts)
288 channel_clear_permission(ssh, FORWARD_USER, FORWARD_LOCAL);
297 channel_add_permission(ssh,
303 channel_clear_permission(ssh, FORWARD_USER, FORWARD_REMOTE);
312 channel_add_permission(ssh,
320 do_authenticated(struct ssh *ssh, Authctxt *authctxt)
328 set_fwdpermit_from_authopts(ssh, auth_opts);
332 channel_disable_admin(ssh, FORWARD_LOCAL);
333 channel_disable_admin(ssh, FORWARD_REMOTE);
336 channel_disable_admin(ssh, FORWARD_LOCAL);
338 channel_permit_all(ssh, FORWARD_LOCAL);
340 channel_disable_admin(ssh, FORWARD_REMOTE);
342 channel_permit_all(ssh, FORWARD_REMOTE);
344 auth_debug_send(ssh);
348 do_authenticated2(ssh, authctxt);
350 do_cleanup(ssh, authctxt);
375 do_exec_no_pty(struct ssh *ssh, Session *s, const char *command)
492 do_child(ssh, s, command);
500 ssh_packet_set_interactive(ssh, s->display != NULL,
509 session_set_fds(ssh, s, pin[1], pout[0], perr[0],
520 session_set_fds(ssh, s, inout[1], inout[1], err[1],
533 do_exec_pty(struct ssh *ssh, Session *s, const char *command)
598 do_login(ssh, s, command);
604 do_child(ssh, s, command);
616 ssh_packet_set_interactive(ssh, 1,
618 session_set_fds(ssh, s, ptyfd, fdout, -1, 1, 1);
627 do_exec(struct ssh *ssh, Session *s, const char *command)
673 ssh_remote_ipaddr(ssh),
674 ssh_remote_port(ssh),
685 ret = do_exec_pty(ssh, s, command);
687 ret = do_exec_no_pty(ssh, s, command);
704 do_login(struct ssh *ssh, Session *s, const char *command)
715 if (ssh_packet_connection_is_on_socket(ssh)) {
716 if (getpeername(ssh_packet_get_connection_in(ssh),
824 do_setup_env(struct ssh *ssh, Session *s, const char *shell)
896 /* read $HOME/.ssh/environment. */
918 ssh_remote_ipaddr(ssh), ssh_remote_port(ssh),
919 ssh_local_port(ssh));
922 laddr = get_local_ipaddr(ssh_packet_get_connection_in(ssh));
924 ssh_remote_ipaddr(ssh), ssh_remote_port(ssh),
925 laddr, ssh_local_port(ssh));
949 * Run $HOME/.ssh/rc, /etc/ssh/sshrc, or xauth (whichever is found
953 do_rc_files(struct ssh *ssh, Session *s, const char *shell)
1169 child_close_fds(struct ssh *ssh)
1178 if (ssh_packet_get_connection_in(ssh) ==
1179 ssh_packet_get_connection_out(ssh))
1180 close(ssh_packet_get_connection_in(ssh));
1182 close(ssh_packet_get_connection_in(ssh));
1183 close(ssh_packet_get_connection_out(ssh));
1190 channel_close_all(ssh);
1217 do_child(struct ssh *ssh, Session *s, const char *command)
1225 sshpkt_fmt_connection_id(ssh, remote_id, sizeof(remote_id));
1228 ssh_packet_clear_keys(ssh);
1233 child_close_fds(ssh);
1255 env = do_setup_env(ssh, s, shell);
1266 child_close_fds(ssh);
1269 * Must take new environment into use so that .ssh/rc,
1270 * /etc/ssh/sshrc and xauth are run in the proper environment.
1315 do_rc_files(ssh, s, shell);
1557 session_window_change_req(struct ssh *ssh, Session *s)
1561 if ((r = sshpkt_get_u32(ssh, &s->col)) != 0 ||
1562 (r = sshpkt_get_u32(ssh, &s->row)) != 0 ||
1563 (r = sshpkt_get_u32(ssh, &s->xpixel)) != 0 ||
1564 (r = sshpkt_get_u32(ssh, &s->ypixel)) != 0 ||
1565 (r = sshpkt_get_end(ssh)) != 0)
1566 sshpkt_fatal(ssh, r, "%s: parse packet", __func__);
1572 session_pty_req(struct ssh *ssh, Session *s)
1581 ssh_packet_disconnect(ssh, "Protocol error: you already have a pty.");
1585 if ((r = sshpkt_get_cstring(ssh, &s->term, NULL)) != 0 ||
1586 (r = sshpkt_get_u32(ssh, &s->col)) != 0 ||
1587 (r = sshpkt_get_u32(ssh, &s->row)) != 0 ||
1588 (r = sshpkt_get_u32(ssh, &s->xpixel)) != 0 ||
1589 (r = sshpkt_get_u32(ssh, &s->ypixel)) != 0)
1590 sshpkt_fatal(ssh, r, "%s: parse packet", __func__);
1609 ssh_tty_parse_modes(ssh, s->ttyfd);
1611 if ((r = sshpkt_get_end(ssh)) != 0)
1612 sshpkt_fatal(ssh, r, "%s: parse packet", __func__);
1622 session_subsystem_req(struct ssh *ssh, Session *s)
1629 if ((r = sshpkt_get_cstring(ssh, &s->subsys, NULL)) != 0 ||
1630 (r = sshpkt_get_end(ssh)) != 0)
1631 sshpkt_fatal(ssh, r, "%s: parse packet", __func__);
1651 channel_set_xtype(ssh, s->chanid, type);
1653 success = do_exec(ssh, s, cmd) == 0;
1666 session_x11_req(struct ssh *ssh, Session *s)
1676 if ((r = sshpkt_get_u8(ssh, &single_connection)) != 0 ||
1677 (r = sshpkt_get_cstring(ssh, &s->auth_proto, NULL)) != 0 ||
1678 (r = sshpkt_get_cstring(ssh, &s->auth_data, NULL)) != 0 ||
1679 (r = sshpkt_get_u32(ssh, &s->screen)) != 0 ||
1680 (r = sshpkt_get_end(ssh)) != 0)
1681 sshpkt_fatal(ssh, r, "%s: parse packet", __func__);
1687 success = session_setup_x11fwd(ssh, s);
1702 session_shell_req(struct ssh *ssh, Session *s)
1706 if ((r = sshpkt_get_end(ssh)) != 0)
1707 sshpkt_fatal(ssh, r, "%s: parse packet", __func__);
1709 channel_set_xtype(ssh, s->chanid, "session:shell");
1711 return do_exec(ssh, s, NULL) == 0;
1715 session_exec_req(struct ssh *ssh, Session *s)
1721 if ((r = sshpkt_get_cstring(ssh, &command, NULL)) != 0 ||
1722 (r = sshpkt_get_end(ssh)) != 0)
1723 sshpkt_fatal(ssh, r, "%s: parse packet", __func__);
1725 channel_set_xtype(ssh, s->chanid, "session:command");
1727 success = do_exec(ssh, s, command) == 0;
1733 session_break_req(struct ssh *ssh, Session *s)
1737 if ((r = sshpkt_get_u32(ssh, NULL)) != 0 || /* ignore */
1738 (r = sshpkt_get_end(ssh)) != 0)
1739 sshpkt_fatal(ssh, r, "%s: parse packet", __func__);
1747 session_env_req(struct ssh *ssh, Session *s)
1753 if ((r = sshpkt_get_cstring(ssh, &name, NULL)) != 0 ||
1754 (r = sshpkt_get_cstring(ssh, &val, NULL)) != 0 ||
1755 (r = sshpkt_get_end(ssh)) != 0)
1756 sshpkt_fatal(ssh, r, "%s: parse packet", __func__);
1784 * Conversion of signals from ssh channel request names.
1806 session_signal_req(struct ssh *ssh, Session *s)
1811 if ((r = sshpkt_get_cstring(ssh, &signame, NULL)) != 0 ||
1812 (r = sshpkt_get_end(ssh)) != 0) {
1848 session_auth_agent_req(struct ssh *ssh, Session *s)
1853 if ((r = sshpkt_get_end(ssh)) != 0)
1854 sshpkt_fatal(ssh, r, "%s: parse packet", __func__);
1864 return auth_input_request_forwarding(ssh, s->pw);
1869 session_input_channel_req(struct ssh *ssh, Channel *c, const char *rtype)
1886 success = session_shell_req(ssh, s);
1888 success = session_exec_req(ssh, s);
1890 success = session_pty_req(ssh, s);
1892 success = session_x11_req(ssh, s);
1894 success = session_auth_agent_req(ssh, s);
1896 success = session_subsystem_req(ssh, s);
1898 success = session_env_req(ssh, s);
1902 success = session_window_change_req(ssh, s);
1904 success = session_break_req(ssh, s);
1906 success = session_signal_req(ssh, s);
1913 session_set_fds(struct ssh *ssh, Session *s,
1922 channel_set_fds(ssh, s->chanid,
1993 session_close_x11(struct ssh *ssh, int id)
1997 if ((c = channel_by_id(ssh, id)) == NULL) {
2002 channel_cancel_cleanup(ssh, id);
2004 chan_mark_dead(ssh, c);
2009 session_close_single_x11(struct ssh *ssh, int id, int force, void *arg)
2015 channel_cancel_cleanup(ssh, id);
2026 session_close_x11(ssh, s->x11_chanids[i]);
2041 session_exit_message(struct ssh *ssh, Session *s, int status)
2047 if ((c = channel_lookup(ssh, s->chanid)) == NULL)
2051 channel_request_start(ssh, s->chanid, "exit-status", 0);
2052 if ((r = sshpkt_put_u32(ssh, WEXITSTATUS(status))) != 0 ||
2053 (r = sshpkt_send(ssh)) != 0)
2054 sshpkt_fatal(ssh, r, "%s: exit reply", __func__);
2057 channel_request_start(ssh, s->chanid, "exit-signal", 0);
2058 if ((r = sshpkt_put_cstring(ssh, sig2name(WTERMSIG(status)))) != 0 ||
2059 (r = sshpkt_put_u8(ssh, WCOREDUMP(status)? 1 : 0)) != 0 ||
2060 (r = sshpkt_put_cstring(ssh, "")) != 0 ||
2061 (r = sshpkt_put_cstring(ssh, "")) != 0 ||
2062 (r = sshpkt_send(ssh)) != 0)
2063 sshpkt_fatal(ssh, r, "%s: exit reply", __func__);
2068 ssh_packet_disconnect(ssh, "wait returned status %04x.",
2084 channel_register_cleanup(ssh, c->self, session_close_by_channel, 1);
2093 chan_write_failed(ssh, c);
2097 session_close(struct ssh *ssh, Session *s)
2103 ssh_remote_ipaddr(ssh),
2104 ssh_remote_port(ssh),
2128 session_close_by_pid(struct ssh *ssh, pid_t pid, int status)
2136 session_exit_message(ssh, s, status);
2147 session_close_by_channel(struct ssh *ssh, int id, int force, void *arg)
2170 channel_cancel_cleanup(ssh, s->chanid);
2175 session_close_x11(ssh, s->x11_chanids[i]);
2181 session_close(ssh, s);
2185 session_destroy_all(struct ssh *ssh, void (*closefunc)(Session *))
2194 session_close(ssh, s);
2228 session_setup_x11fwd(struct ssh *ssh, Session *s)
2236 ssh_packet_send_debug(ssh, "X11 forwarding disabled by key options.");
2245 ssh_packet_send_debug(ssh, "No xauth program; cannot forward X11.");
2252 if (x11_create_display_inet(ssh, options.x11_display_offset,
2259 channel_register_cleanup(ssh, s->x11_chanids[i],
2289 do_authenticated2(struct ssh *ssh, Authctxt *authctxt)
2291 server_loop2(ssh, authctxt);
2295 do_cleanup(struct ssh *ssh, Authctxt *authctxt)
2340 session_destroy_all(ssh, session_pty_cleanup2);
2346 session_get_remote_name_or_ip(struct ssh *ssh, u_int utmp_size, int use_dns)
2351 remote = auth_get_canonical_hostname(ssh, use_dns);
2353 remote = ssh_remote_ipaddr(ssh);