version 1.337, 2024/02/01 02:37:33 |
version 1.338, 2024/05/17 00:30:24 |
|
|
{ |
{ |
socklen_t fromlen; |
socklen_t fromlen; |
struct sockaddr_storage from; |
struct sockaddr_storage from; |
struct passwd * pw = s->pw; |
|
pid_t pid = getpid(); |
|
|
|
/* |
/* |
* Get IP address of client. If the connection is not a socket, let |
* Get IP address of client. If the connection is not a socket, let |
|
|
} |
} |
} |
} |
|
|
/* Record that there was a login on that tty from the remote host. */ |
|
if (!use_privsep) |
|
record_login(pid, s->tty, pw->pw_name, pw->pw_uid, |
|
session_get_remote_name_or_ip(ssh, utmp_len, |
|
options.use_dns), |
|
(struct sockaddr *)&from, fromlen); |
|
|
|
if (check_quietlogin(s, command)) |
if (check_quietlogin(s, command)) |
return; |
return; |
|
|
|
|
|
|
/* Allocate a pty and open it. */ |
/* Allocate a pty and open it. */ |
debug("Allocating pty."); |
debug("Allocating pty."); |
if (!PRIVSEP(pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, |
if (!mm_pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, sizeof(s->tty))) { |
sizeof(s->tty)))) { |
|
free(s->term); |
free(s->term); |
s->term = NULL; |
s->term = NULL; |
s->ptyfd = -1; |
s->ptyfd = -1; |
|
|
if ((r = sshpkt_get_end(ssh)) != 0) |
if ((r = sshpkt_get_end(ssh)) != 0) |
sshpkt_fatal(ssh, r, "%s: parse packet", __func__); |
sshpkt_fatal(ssh, r, "%s: parse packet", __func__); |
|
|
if (!use_privsep) |
|
pty_setowner(s->pw, s->tty); |
|
|
|
/* Set window size from the packet. */ |
/* Set window size from the packet. */ |
pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel); |
pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel); |
|
|
|
|
signame, s->forced ? "forced-command" : "subsystem"); |
signame, s->forced ? "forced-command" : "subsystem"); |
goto out; |
goto out; |
} |
} |
if (!use_privsep || mm_is_monitor()) { |
if (mm_is_monitor()) { |
error_f("session signalling requires privilege separation"); |
error_f("session signalling requires privilege separation"); |
goto out; |
goto out; |
} |
} |
|
|
void |
void |
session_pty_cleanup(Session *s) |
session_pty_cleanup(Session *s) |
{ |
{ |
PRIVSEP(session_pty_cleanup2(s)); |
mm_session_pty_cleanup2(s); |
} |
} |
|
|
static char * |
static char * |
|
|
* Cleanup ptys/utmp only if privsep is disabled, |
* Cleanup ptys/utmp only if privsep is disabled, |
* or if running in monitor. |
* or if running in monitor. |
*/ |
*/ |
if (!use_privsep || mm_is_monitor()) |
if (mm_is_monitor()) |
session_destroy_all(ssh, session_pty_cleanup2); |
session_destroy_all(ssh, session_pty_cleanup2); |
} |
} |
|
|