Subject: bin/272: w(1) can get confused with non-ttys in utmp
To: None <gnats-admin>
From: John Brezak <brezak@ch.hp.com>
List: netbsd-bugs
Date: 05/31/1994 19:50:04
>Number:         272
>Category:       bin
>Synopsis:       w(1) can get confused with non-tty's in utmp.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 31 19:50:03 1994
>Originator:     John Brezak
>Organization:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 John Brezak                    UUCP:     uunet!apollo.hp!brezak
 Hewlett Packard/Apollo         Internet: brezak@ch.hp.com
 300 Apollo Drive               Phone:    (508) 436-4915
 Chelmsford, Massachusetts      Fax:      (508) 436-5103
>Release:        5/30/94
>Environment:
	
System: NetBSD sussex 0.9B NetBSD 0.9B (SUSSEX) #3: Tue May 31 05:52:59 EDT 1994 brezak@sussex:/u0/src/netbsd/sys/arch/i386/compile/SUSSEX i386


>Description:
	If there is a non-tty entry in utmp, w(1) will exit with an error.
However there are legitimate non-tty entries, for instance an xlogin via
xdm can be identified with the xlogin program. In this case there is an
entry with the display name as the ut_tty.
>How-To-Repeat:
>Fix:
	A slight change to the logic to return a status and ignore the tty.
Instead of exitting with an err().

*** w.c~	Mon May  9 06:52:30 1994
--- w.c	Tue May 31 22:20:50 1994
***************
*** 191,197 ****
  		*nextp = ep;
  		nextp = &(ep->next);
  		memmove(&(ep->utmp), &utmp, sizeof(struct utmp));
! 		stp = ttystat(ep->utmp.ut_line);
  		ep->tdev = stp->st_rdev;
  #ifdef CPU_CONSDEV
  		/*
--- 191,198 ----
  		*nextp = ep;
  		nextp = &(ep->next);
  		memmove(&(ep->utmp), &utmp, sizeof(struct utmp));
! 		if (!(stp = ttystat(ep->utmp.ut_line)))
! 			continue;
  		ep->tdev = stp->st_rdev;
  #ifdef CPU_CONSDEV
  		/*
***************
*** 409,415 ****
  
  	(void)snprintf(ttybuf, sizeof(ttybuf), "%s/%s", _PATH_DEV, line);
  	if (stat(ttybuf, &sb))
! 		err(1, "%s", ttybuf);
  	return (&sb);
  }
  
--- 410,416 ----
  
  	(void)snprintf(ttybuf, sizeof(ttybuf), "%s/%s", _PATH_DEV, line);
  	if (stat(ttybuf, &sb))
! 		return (NULL);
  	return (&sb);
  }
  

>Audit-Trail:
>Unformatted:


------------------------------------------------------------------------------