If I telnet in to my Gentoo machine and then log out, the number of users given by the w command seems to reflect that telnet login still even though the session has been closed. It's easier to describe this visually. Here are the relevant entries from the last command: jon pty/s0 scfwpr07.sc.inte Fri May 9 08:34 still logged in jon pty/s0 192.168.0.2 Fri May 9 06:36 - 08:34 (01:57) The first one is my current SSH session into the machine. The second line is a telnet session that was closed as correctly shown by the last command. Now, below is the output of the w command: 08:54:07 up 11:33, 2 users, load average: 0.00, 0.36, 0.55 USER TTY LOGIN@ IDLE JCPU PCPU WHAT jon pty/s0 08:34 0.00s 0.02s 0.01s w As you can see there is only one person logged in to the machine but it says "2 users." This doesn't appear to happen with SSH sessions only telnet sessions. Reproducible: Always Steps to Reproduce: 1. Telnet to Gentoo system 2. Logout of telnet session 3. Type w on the Gentoo system; the number of users still accounts for the telnet session. Expected Results: The output of the w command should only show 1 user. Portage 2.0.47-r10 (default-x86-1.4, gcc-3.2.2, glibc-2.3.1-r4) ================================================================= System uname: 2.4.20-gentoo-r2 i686 Intel(R) Pentium(R) 4 CPU 3.06GHz GENTOO_MIRRORS="http://gentoo.oregonstate.edu/ http://distro.ibiblio.org/pub/Linux/distributions/gentoo" CONFIG_PROTECT="/etc /var/qmail/control /usr/kde/2/share/config /usr/kde/3/share/config /var/bind /usr/X11R6/lib/X11/xkb /usr/kde/3.1/share/config /usr/share/config" CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d" PORTDIR="/usr/portage" DISTDIR="/usr/portage/distfiles" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR_OVERLAY="" USE="x86 oss 3dnow apm avi crypt cups encode gif jpeg gnome libg++ mikmod mmx mpeg ncurses nls pdflib png quicktime spell truetype xml2 xmms xv zlib gtkhtml gdbm berkdb slang readline arts tetex bonobo svga java guile sdl gpm tcpd pam libwww ssl perl python esd imlib oggvorbis gtk motif opengl X qt kde maildir mozilla tcltk" COMPILER="gcc3" CHOST="i686-pc-linux-gnu" CFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer -mmmx -msse -msse2" CXXFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer -mmmx -msse -msse2" ACCEPT_KEYWORDS="x86" MAKEOPTS="-j3" AUTOCLEAN="yes" SYNC="rsync://rsync.gentoo.org/gentoo-portage" FEATURES="sandbox ccache"
what version of the telnet server ? how are you running the telnet server ? why are you using telnet ? :)
Telnet server is version 0.17-r3. Telnet is spawned through xinetd (version 2.3.11). This is inside a trusted network (my home LAN) so I'm not concerned about using telnet in here. Over the Internet I always use SSH.
Try enabling `Unix98 PTY support' (under Character devices) in the kernel config on the machine running telnetd (not to be confused with `/dev/pts' support under File systems). In case of the telnet connection, * telnetd calls openpty() to allocate a pty pair. * telnetd launches login, which calls ttyname(stdin) to obtain its terminal name. * login uses that info when filling in the utmp entry * after the session ends, telnetd tries to locate and clear its utmp entry by line name (using the value returned from openpty()) Without Unix98 PTYs, openpty() uses the bsd-style (non-devfs) naming when finding a free master pty (getpt) as well as when calculating the name of the slave (ptsname) and returns that name to the caller. But, since that's a symbolic link under devfs, ttyname() sees the dereferenced value when looking it up in `/proc/self/fd/'. In the above scenario, login writes `pty/s0' to utmp, while telnetd tries to wipe `ttyp0'. (with CONFIG_UNIX98_PTYS=y they'd both see `pts/0') Test program that demostrates this, run with Unix98 PTY support disabled: --- /* gcc -lutil -o pty_test pty_test.c */ #include <pty.h> #include <stdio.h> int main() { int masterfd,slavefd; char sname[4096]; if(openpty(&masterfd, &slavefd, sname, NULL, NULL)) { perror("openpty()"); return 1; } printf("openpty(): %s\n" "ttyname(): %s\n", sname, ttyname(slavefd)); return 0; } ---
no feedback from user and proposed solution seems to work