diff options
author | Ed Maste <emaste@FreeBSD.org> | 2023-02-05 18:04:12 +0000 |
---|---|---|
committer | Ed Maste <emaste@FreeBSD.org> | 2023-02-05 18:04:12 +0000 |
commit | 7ee81174ca89a92a4c1686170d433dae500ae144 (patch) | |
tree | c615e38bc01eb9ce5bf6cfb6f45a4f4b5efe5588 /session.c | |
parent | 56fae06595918644df9cfd2f285777195c8d29b8 (diff) | |
download | src-7ee81174ca89a92a4c1686170d433dae500ae144.tar.gz src-7ee81174ca89a92a4c1686170d433dae500ae144.zip |
Vendor import of OpenSSH 9.2p1vendor/openssh/9.2p1
Diffstat (limited to 'session.c')
-rw-r--r-- | session.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/session.c b/session.c index e67d24d23c99..f30d7ac519ac 100644 --- a/session.c +++ b/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.330 2022/02/08 08:59:12 dtucker Exp $ */ +/* $OpenBSD: session.c,v 1.333 2023/01/06 02:42:34 djm Exp $ */ /* * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * All rights reserved @@ -222,7 +222,7 @@ auth_input_request_forwarding(struct ssh *ssh, struct passwd * pw) goto authsock_err; /* Allocate a channel for the authentication agent socket. */ - nc = channel_new(ssh, "auth socket", + nc = channel_new(ssh, "auth-listener", SSH_CHANNEL_AUTH_SOCKET, sock, sock, -1, CHAN_X11_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT, 0, "auth socket", 1); @@ -1955,7 +1955,7 @@ session_subsystem_req(struct ssh *ssh, Session *s) { struct stat st; int r, success = 0; - char *prog, *cmd; + char *prog, *cmd, *type; u_int i; if ((r = sshpkt_get_cstring(ssh, &s->subsys, NULL)) != 0 || @@ -1978,6 +1978,10 @@ session_subsystem_req(struct ssh *ssh, Session *s) s->is_subsystem = SUBSYSTEM_EXT; debug("subsystem: exec() %s", cmd); } + xasprintf(&type, "session:subsystem:%s", + options.subsystem_name[i]); + channel_set_xtype(ssh, s->chanid, type); + free(type); success = do_exec(ssh, s, cmd) == 0; break; } @@ -2033,6 +2037,9 @@ session_shell_req(struct ssh *ssh, Session *s) if ((r = sshpkt_get_end(ssh)) != 0) sshpkt_fatal(ssh, r, "%s: parse packet", __func__); + + channel_set_xtype(ssh, s->chanid, "session:shell"); + return do_exec(ssh, s, NULL) == 0; } @@ -2047,6 +2054,8 @@ session_exec_req(struct ssh *ssh, Session *s) (r = sshpkt_get_end(ssh)) != 0) sshpkt_fatal(ssh, r, "%s: parse packet", __func__); + channel_set_xtype(ssh, s->chanid, "session:command"); + success = do_exec(ssh, s, command) == 0; free(command); return success; @@ -2335,7 +2344,7 @@ session_close_x11(struct ssh *ssh, int id) } static void -session_close_single_x11(struct ssh *ssh, int id, void *arg) +session_close_single_x11(struct ssh *ssh, int id, int force, void *arg) { Session *s; u_int i; @@ -2469,7 +2478,7 @@ session_close_by_pid(struct ssh *ssh, pid_t pid, int status) * the session 'child' itself dies */ void -session_close_by_channel(struct ssh *ssh, int id, void *arg) +session_close_by_channel(struct ssh *ssh, int id, int force, void *arg) { Session *s = session_by_channel(id); u_int i; @@ -2482,12 +2491,14 @@ session_close_by_channel(struct ssh *ssh, int id, void *arg) if (s->pid != 0) { debug_f("channel %d: has child, ttyfd %d", id, s->ttyfd); /* - * delay detach of session, but release pty, since - * the fd's to the child are already closed + * delay detach of session (unless this is a forced close), + * but release pty, since the fd's to the child are already + * closed */ if (s->ttyfd != -1) session_pty_cleanup(s); - return; + if (!force) + return; } /* detach by removing callback */ channel_cancel_cleanup(ssh, s->chanid); |