From dd5567759d5560dbd7d3914dcd376f18b1f0d386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Groenvall?= Date: Mon, 16 Oct 1995 10:35:49 +0000 Subject: [PATCH] Under SunOS5 the same utmpx slot got used by sevral sessions. Courtesy of gertz@lysator.liu.se. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@150 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/telnet/telnetd/sys_term.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/appl/telnet/telnetd/sys_term.c b/appl/telnet/telnetd/sys_term.c index 42e105a5b..00241c649 100644 --- a/appl/telnet/telnetd/sys_term.c +++ b/appl/telnet/telnetd/sys_term.c @@ -1579,6 +1579,8 @@ start_login(host, autologin, name) struct arg_val argv; extern char *getenv(); #ifdef HAVE_UTMPX_H + char id_buf[3]; + int ptynum; register int pid = getpid(); struct utmpx utmpx; #endif @@ -1596,10 +1598,14 @@ start_login(host, autologin, name) SCPYN(utmpx.ut_user, ".telnet"); SCPYN(utmpx.ut_line, line + sizeof("/dev/") - 1); utmpx.ut_pid = pid; + /* Derive utmp ID from pty slave number */ + if(sscanf(line, "%*[^0-9]%d", &ptynum) != 1 || ptynum > 255) + fatal(net, "pty slave number incorrect"); + sprintf(id_buf, "%02x", ptynum); utmpx.ut_id[0] = 't'; utmpx.ut_id[1] = 'n'; - utmpx.ut_id[2] = SC_WILDC; - utmpx.ut_id[3] = SC_WILDC; + utmpx.ut_id[2] = id_buf[0]; + utmpx.ut_id[3] = id_buf[1]; utmpx.ut_type = LOGIN_PROCESS; (void) time(&utmpx.ut_tv.tv_sec); if (pututxline(&utmpx) == NULL)