summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'session.c')
-rw-r--r--session.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/session.c b/session.c
index 0679d837c..c490f087e 100644
--- a/session.c
+++ b/session.c
@@ -8,7 +8,7 @@
8 */ 8 */
9 9
10#include "includes.h" 10#include "includes.h"
11RCSID("$OpenBSD: session.c,v 1.8 2000/04/29 16:06:08 markus Exp $"); 11RCSID("$OpenBSD: session.c,v 1.12 2000/05/03 18:03:07 markus Exp $");
12 12
13#include "xmalloc.h" 13#include "xmalloc.h"
14#include "ssh.h" 14#include "ssh.h"
@@ -57,6 +57,7 @@ struct Session {
57Session *session_new(void); 57Session *session_new(void);
58void session_set_fds(Session *s, int fdin, int fdout, int fderr); 58void session_set_fds(Session *s, int fdin, int fdout, int fderr);
59void session_pty_cleanup(Session *s); 59void session_pty_cleanup(Session *s);
60void session_proctitle(Session *s);
60void do_exec_pty(Session *s, const char *command, struct passwd * pw); 61void do_exec_pty(Session *s, const char *command, struct passwd * pw);
61void do_exec_no_pty(Session *s, const char *command, struct passwd * pw); 62void do_exec_no_pty(Session *s, const char *command, struct passwd * pw);
62 63
@@ -240,6 +241,8 @@ do_authenticated(struct passwd * pw)
240 tty_parse_modes(s->ttyfd, &n_bytes); 241 tty_parse_modes(s->ttyfd, &n_bytes);
241 packet_integrity_check(plen, 4 + dlen + 4 * 4 + n_bytes, type); 242 packet_integrity_check(plen, 4 + dlen + 4 * 4 + n_bytes, type);
242 243
244 session_proctitle(s);
245
243 /* Indicate that we now have a pty. */ 246 /* Indicate that we now have a pty. */
244 success = 1; 247 success = 1;
245 have_pty = 1; 248 have_pty = 1;
@@ -312,7 +315,7 @@ do_authenticated(struct passwd * pw)
312 break; 315 break;
313 } 316 }
314 debug("Received TCP/IP port forwarding request."); 317 debug("Received TCP/IP port forwarding request.");
315 channel_input_port_forward_request(pw->pw_uid == 0); 318 channel_input_port_forward_request(pw->pw_uid == 0, options.gateway_ports);
316 success = 1; 319 success = 1;
317 break; 320 break;
318 321
@@ -397,7 +400,7 @@ do_exec_no_pty(Session *s, const char *command, struct passwd * pw)
397 if (s == NULL) 400 if (s == NULL)
398 fatal("do_exec_no_pty: no session"); 401 fatal("do_exec_no_pty: no session");
399 402
400 setproctitle("%s@notty", pw->pw_name); 403 session_proctitle(s);
401 404
402#ifdef USE_PAM 405#ifdef USE_PAM
403 do_pam_setcred(); 406 do_pam_setcred();
@@ -527,7 +530,6 @@ do_exec_pty(Session *s, const char *command, struct passwd * pw)
527 last_login_time = get_last_login_time(pw->pw_uid, pw->pw_name, 530 last_login_time = get_last_login_time(pw->pw_uid, pw->pw_name,
528 buf, sizeof(buf)); 531 buf, sizeof(buf));
529 } 532 }
530 setproctitle("%s@%s", pw->pw_name, strrchr(s->tty, '/') + 1);
531 533
532#ifdef USE_PAM 534#ifdef USE_PAM
533 do_pam_session(pw->pw_name, s->tty); 535 do_pam_session(pw->pw_name, s->tty);
@@ -563,7 +565,7 @@ do_exec_pty(Session *s, const char *command, struct passwd * pw)
563 /* Close the extra descriptor for the pseudo tty. */ 565 /* Close the extra descriptor for the pseudo tty. */
564 close(ttyfd); 566 close(ttyfd);
565 567
566///XXXX ? move to do_child() ?? 568/* XXXX ? move to do_child() ??*/
567 /* 569 /*
568 * Get IP address of client. This is needed because we want 570 * Get IP address of client. This is needed because we want
569 * to record where the user logged in from. If the 571 * to record where the user logged in from. If the
@@ -1257,6 +1259,8 @@ session_pty_req(Session *s)
1257 /* Get window size from the packet. */ 1259 /* Get window size from the packet. */
1258 pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel); 1260 pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel);
1259 1261
1262 session_proctitle(s);
1263
1260 /* XXX parse and set terminal modes */ 1264 /* XXX parse and set terminal modes */
1261 xfree(term_modes); 1265 xfree(term_modes);
1262 return 1; 1266 return 1;
@@ -1499,6 +1503,7 @@ session_close(Session *s)
1499{ 1503{
1500 session_pty_cleanup(s); 1504 session_pty_cleanup(s);
1501 session_free(s); 1505 session_free(s);
1506 session_proctitle(s);
1502} 1507}
1503 1508
1504void 1509void
@@ -1542,6 +1547,34 @@ session_close_by_channel(int id, void *arg)
1542 } 1547 }
1543} 1548}
1544 1549
1550char *
1551session_tty_list(void)
1552{
1553 static char buf[1024];
1554 int i;
1555 buf[0] = '\0';
1556 for(i = 0; i < MAX_SESSIONS; i++) {
1557 Session *s = &sessions[i];
1558 if (s->used && s->ttyfd != -1) {
1559 if (buf[0] != '\0')
1560 strlcat(buf, ",", sizeof buf);
1561 strlcat(buf, strrchr(s->tty, '/') + 1, sizeof buf);
1562 }
1563 }
1564 if (buf[0] == '\0')
1565 strlcpy(buf, "notty", sizeof buf);
1566 return buf;
1567}
1568
1569void
1570session_proctitle(Session *s)
1571{
1572 if (s->pw == NULL)
1573 error("no user for session %d", s->self);
1574 else
1575 setproctitle("%s@%s", s->pw->pw_name, session_tty_list());
1576}
1577
1545void 1578void
1546do_authenticated2(void) 1579do_authenticated2(void)
1547{ 1580{