From e247cc402bc391650f014316363dbce78ad85dc7 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Sun, 7 May 2000 12:03:14 +1000 Subject: - Remove references to SSLeay. - Big OpenBSD CVS update - markus@cvs.openbsd.org [clientloop.c] - typo [session.c] - update proctitle on pty alloc/dealloc, e.g. w/ windows client [session.c] - update proctitle for proto 1, too [channels.h nchan.c serverloop.c session.c sshd.c] - use c-style comments - deraadt@cvs.openbsd.org [scp.c] - more atomicio - markus@cvs.openbsd.org [channels.c] - set O_NONBLOCK [ssh.1] - update AUTHOR [readconf.c ssh-keygen.c ssh.h] - default DSA key file ~/.ssh/id_dsa [clientloop.c] - typo, rm verbose debug - deraadt@cvs.openbsd.org [ssh-keygen.1] - document DSA use of ssh-keygen [sshd.8] - a start at describing what i understand of the DSA side [ssh-keygen.1] - document -X and -x [ssh-keygen.c] - simplify usage - markus@cvs.openbsd.org [sshd.8] - there is no rhosts_dsa [ssh-keygen.1] - document -y, update -X,-x [nchan.c] - fix close for non-open ssh1 channels [servconf.c servconf.h ssh.h sshd.8 sshd.c ] - s/DsaKey/HostDSAKey/, document option [sshconnect2.c] - respect number_of_password_prompts [channels.c channels.h servconf.c servconf.h session.c sshd.8] - GatewayPorts for sshd, ok deraadt@ [ssh-add.1 ssh-agent.1 ssh.1] - more doc on: DSA, id_dsa, known_hosts2, authorized_keys2 [ssh.1] - more info on proto 2 [sshd.8] - sync AUTHOR w/ ssh.1 [key.c key.h sshconnect.c] - print key type when talking about host keys [packet.c] - clear padding in ssh2 [dsa.c key.c radix.c ssh.h sshconnect1.c uuencode.c uuencode.h] - replace broken uuencode w/ libc b64_ntop [auth2.c] - log failure before sending the reply [key.c radix.c uuencode.c] - remote trailing comments before calling __b64_pton [auth2.c readconf.c readconf.h servconf.c servconf.h ssh.1] [sshconnect2.c sshd.8] - add DSAAuthetication option to ssh/sshd, document SSH2 in sshd.8 - Bring in b64_ntop and b64_pton from OpenBSD libc (bsd-base64.[ch]) --- session.c | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'session.c') diff --git a/session.c b/session.c index 0679d837..c490f087 100644 --- a/session.c +++ b/session.c @@ -8,7 +8,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: session.c,v 1.8 2000/04/29 16:06:08 markus Exp $"); +RCSID("$OpenBSD: session.c,v 1.12 2000/05/03 18:03:07 markus Exp $"); #include "xmalloc.h" #include "ssh.h" @@ -57,6 +57,7 @@ struct Session { Session *session_new(void); void session_set_fds(Session *s, int fdin, int fdout, int fderr); void session_pty_cleanup(Session *s); +void session_proctitle(Session *s); void do_exec_pty(Session *s, const char *command, struct passwd * pw); void do_exec_no_pty(Session *s, const char *command, struct passwd * pw); @@ -240,6 +241,8 @@ do_authenticated(struct passwd * pw) tty_parse_modes(s->ttyfd, &n_bytes); packet_integrity_check(plen, 4 + dlen + 4 * 4 + n_bytes, type); + session_proctitle(s); + /* Indicate that we now have a pty. */ success = 1; have_pty = 1; @@ -312,7 +315,7 @@ do_authenticated(struct passwd * pw) break; } debug("Received TCP/IP port forwarding request."); - channel_input_port_forward_request(pw->pw_uid == 0); + channel_input_port_forward_request(pw->pw_uid == 0, options.gateway_ports); success = 1; break; @@ -397,7 +400,7 @@ do_exec_no_pty(Session *s, const char *command, struct passwd * pw) if (s == NULL) fatal("do_exec_no_pty: no session"); - setproctitle("%s@notty", pw->pw_name); + session_proctitle(s); #ifdef USE_PAM do_pam_setcred(); @@ -527,7 +530,6 @@ do_exec_pty(Session *s, const char *command, struct passwd * pw) last_login_time = get_last_login_time(pw->pw_uid, pw->pw_name, buf, sizeof(buf)); } - setproctitle("%s@%s", pw->pw_name, strrchr(s->tty, '/') + 1); #ifdef USE_PAM do_pam_session(pw->pw_name, s->tty); @@ -563,7 +565,7 @@ do_exec_pty(Session *s, const char *command, struct passwd * pw) /* Close the extra descriptor for the pseudo tty. */ close(ttyfd); -///XXXX ? move to do_child() ?? +/* XXXX ? move to do_child() ??*/ /* * Get IP address of client. This is needed because we want * to record where the user logged in from. If the @@ -1257,6 +1259,8 @@ session_pty_req(Session *s) /* Get window size from the packet. */ pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel); + session_proctitle(s); + /* XXX parse and set terminal modes */ xfree(term_modes); return 1; @@ -1499,6 +1503,7 @@ session_close(Session *s) { session_pty_cleanup(s); session_free(s); + session_proctitle(s); } void @@ -1542,6 +1547,34 @@ session_close_by_channel(int id, void *arg) } } +char * +session_tty_list(void) +{ + static char buf[1024]; + int i; + buf[0] = '\0'; + for(i = 0; i < MAX_SESSIONS; i++) { + Session *s = &sessions[i]; + if (s->used && s->ttyfd != -1) { + if (buf[0] != '\0') + strlcat(buf, ",", sizeof buf); + strlcat(buf, strrchr(s->tty, '/') + 1, sizeof buf); + } + } + if (buf[0] == '\0') + strlcpy(buf, "notty", sizeof buf); + return buf; +} + +void +session_proctitle(Session *s) +{ + if (s->pw == NULL) + error("no user for session %d", s->self); + else + setproctitle("%s@%s", s->pw->pw_name, session_tty_list()); +} + void do_authenticated2(void) { -- cgit v1.2.3