Subject: bin/17999: login(1) caller (telnetd and rlogind) must cleanup utmpx entry
To: None <gnats-bugs@gnats.netbsd.org>
From: None <naoki@fukaumi.org>
List: netbsd-bugs
Date: 08/20/2002 16:24:53
>Number:         17999
>Category:       bin
>Synopsis:       login(1) caller (telnetd and rlogind) must cleanup utmpx entry
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 20 00:25:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     FUKAUMI Naoki
>Release:        NetBSD 1.6F 20020812-1.6F
>Organization:
	FUKAUMI Naoki
>Environment:
System: NetBSD tlabo3.space.ad.jp 1.6F NetBSD 1.6F (GENERIC) #0: Wed Aug 14 16:13:18 JST 2002 root@sparc64.naobsd.org:/usr/obj/sparc64/sys/arch/sparc64/compile/GENERIC sparc64
Architecture: sparc64
Machine: sparc64
>Description:
	(I don't read any spec. docs like POSIX, SUSv2. If I'm wrong,
	 I'm sorry :)

	After login(1) support utmpx, login(1) caller (such as telnetd
	and rlogind) must cleanup utmpx entry when child login process
	is terminated.

>How-To-Repeat:
	Login via telnetd or rlogind, then logout. See utmpx or w(1)
	output from another terminal. You can see warning about logouted
	session is alive in utmpx.

>Fix:
	Special thanks to ume@freebsd.org, he advised me what's wrong,
	and how to fix this problem.
	(He found this problem on FreeBSD ported our utmpx code :)

	Here is adhoc patch, idea from sshd::record_logout(). Need more
	tweak!
	(#ifdef SUPPORT_UTMPX etc, and cleanup telnetd entirely...)

--- src/libexec/telnetd/sys_term.c.orig	Mon Sep  3 03:32:35 2001
+++ src/libexec/telnetd/sys_term.c	Mon Aug 19 17:37:24 2002
@@ -1789,6 +1789,8 @@
 	p = line + sizeof("/dev/") - 1;
 	if (logout(p))
 		logwtmp(p, "", "");
+	if (logoutx(p, 0, DEAD_PROCESS))
+		logwtmpx(p, "", "", 0, DEAD_PROCESS);
 	(void)chmod(line, 0666);
 	(void)chown(line, 0, 0);
 	c = *p; *p = 'p';
--- src/libexec/rlogind/rlogind.c.orig	Fri Aug  2 22:47:36 2002
+++ src/libexec/rlogind/rlogind.c	Mon Aug 19 17:39:29 2002
@@ -607,6 +607,8 @@
 	p = line + sizeof(_PATH_DEV) - 1;
 	if (logout(p))
 		logwtmp(p, "", "");
+	if (logoutx(p, 0, DEAD_PROCESS))
+		logwtmpx(p, "", "", 0, DEAD_PROCESS);
 	(void)chmod(line, 0666);
 	(void)chown(line, 0, 0);
 	c = *p; *p = 'p';
>Release-Note:
>Audit-Trail:
>Unformatted: