From nobody@www.freebsd.org  Fri May 10 11:03:43 2002
Return-Path: <nobody@www.freebsd.org>
Received: from nwww.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by hub.freebsd.org (Postfix) with ESMTP id CE1D237B400
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 10 May 2002 11:03:42 -0700 (PDT)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by nwww.freebsd.org (8.12.2/8.12.2) with ESMTP id g4AI5ShG005036
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 10 May 2002 11:05:28 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.2/8.12.2/Submit) id g4AI5SI1005035;
	Fri, 10 May 2002 11:05:28 -0700 (PDT)
Message-Id: <200205101805.g4AI5SI1005035@www.freebsd.org>
Date: Fri, 10 May 2002 11:05:28 -0700 (PDT)
From: Sandeep Kumar <skumar@juniper.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: w command still shows the user logged in, even after the telnet session has been closed.
X-Send-Pr-Version: www-1.0

>Number:         37934
>Category:       bin
>Synopsis:       w command still shows the user logged in, even after the telnet session has been closed.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    jmallett
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 10 11:10:01 PDT 2002
>Closed-Date:    Sun Jun 16 19:49:42 PDT 2002
>Last-Modified:  Sun Jun 16 19:49:42 PDT 2002
>Originator:     Sandeep Kumar
>Release:        4.2
>Organization:
Juniper Networks
>Environment:
FreeBSD foobar.juniper.net 4.2-RELEASE FreeBSD 4.2-RELEASE #0
>Description:
 w shows the user still logged in, because logout wtmp entry not being added by telnetd. 
>How-To-Repeat:
      Open and close telnet sessions  and then execute a w command on the destination machine. You may find a "Still logged in" entry for the closed session.
>Fix:
      Block all signals before clearing the utmp entry. We don't want
   to be called again after calling logout() and then not add the wtmp
   entry because of not finding the corresponding entry in utmp. Here is the unified diff for the fix.

Index: libexec/telnetd/sys_term.c
===================================================================
retrieving revision 1.3
retrieving revision 1.4
diff -p -u -r1.3 -r1.4
--- libexec/telnetd/sys_term.c  2002/01/09 18:18:13     1.3
+++ libexec/telnetd/sys_term.c  2002/02/11 21:00:28     1.4
@@ -1839,8 +1839,16 @@ cleanup(sig)
 #ifndef        PARENT_DOES_UTMP
 # if (BSD > 43) || defined(convex)
        char *p;
+       sigset_t mask;

        p = line + sizeof(_PATH_DEV) - 1;
+
+       /* Block all signals before clearing the utmp entry. We don't want
+        * to be called again after calling logout() and then not add the wtmp
+        * entry because of not finding the corresponding entry in utmp.
+        */
+       sigfillset(&mask);
+       sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0);
        if (logout(p))
                logwtmp(p, "", "");
        (void)chmod(line, 0666);

>Release-Note:
>Audit-Trail:

From: Sandeep Kumar <skumar@juniper.net>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/37934: w command still shows the user logged in, even after the telnet session has been closed.
Date: Fri, 10 May 2002 11:12:53 -0700

 Forgot to mention that the signal received is SIGCHLD, because of the 
 login shell (forked from telnetd) exiting.
 
Responsible-Changed-From-To: freebsd-bugs->jmallett 
Responsible-Changed-By: jmallett 
Responsible-Changed-When: Mon May 27 01:14:14 PDT 2002 
Responsible-Changed-Why:  
Over to me. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=37934 
State-Changed-From-To: open->patched 
State-Changed-By: jmallett 
State-Changed-When: Mon May 27 01:14:41 PDT 2002 
State-Changed-Why:  
Fix committed to CURRENT, thanks!  Awaiting merge to STABLE. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=37934 
State-Changed-From-To: patched->closed 
State-Changed-By: jmallett 
State-Changed-When: Sun Jun 16 19:48:11 PDT 2002 
State-Changed-Why:  
This has been integrated into RELENG_4, thanks! :) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=37934 
>Unformatted:
