summaryrefslogtreecommitdiff
path: root/usr.bin/ssh
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2000-05-02 07:32:45 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2000-05-02 07:32:45 +0000
commitb34b0f363cb20f99ca067ace874051569ce38148 (patch)
tree594c362cd135fb1e3cf86ffde4b2d0bbb57af94d /usr.bin/ssh
parent4daf9afdae3620553685c2b6d940a511ab374bbd (diff)
update proctitle on pty alloc/dealloc, e.g. w/ windows client
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r--usr.bin/ssh/session.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/usr.bin/ssh/session.c b/usr.bin/ssh/session.c
index 0f5fb9e1da0..68574b87d32 100644
--- a/usr.bin/ssh/session.c
+++ b/usr.bin/ssh/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.9 2000/05/02 07:32:44 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);
@@ -392,7 +393,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);
/* Fork the child. */
if ((pid = fork()) == 0) {
@@ -518,7 +519,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);
/* Fork the child. */
if ((pid = fork()) == 0) {
@@ -1184,6 +1184,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;
@@ -1426,6 +1428,7 @@ session_close(Session *s)
{
session_pty_cleanup(s);
session_free(s);
+ session_proctitle(s);
}
void
@@ -1469,6 +1472,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)
{