From jmg@garfield.telepac.pt  Mon Jul 28 21:10:56 1997
Received: from garfield.telepac.pt (sj1-p3.telepac.pt [194.65.177.67])
          by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id VAA05754
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 28 Jul 1997 21:10:53 -0700 (PDT)
Received: (from jmg@localhost)
	by garfield.telepac.pt (8.8.6/8.8.5) id QAA00784;
	Mon, 28 Jul 1997 16:52:50 +0100 (WEST)
Message-Id: <199707281552.QAA00784@garfield.telepac.pt>
Date: Mon, 28 Jul 1997 16:52:50 +0100 (WEST)
From: jmg@bug.fe.up.pt
Reply-To: ee96199@tom.fe.up.pt
To: FreeBSD-gnats-submit@freebsd.org
Subject: w command
X-Send-Pr-Version: 3.2

>Number:         4187
>Category:       bin
>Synopsis:       The w command should have a larger tty field
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 28 21:20:01 PDT 1997
>Closed-Date:    Sun Apr 19 11:32:08 PDT 1998
>Last-Modified:  Sun Apr 19 11:32:29 PDT 1998
>Originator:     Jorge M. Goncalves
>Release:        FreeBSD 2.2-STABLE i386
>Organization:
>Environment:

	All FreeBSD releases.

>Description:

	Like most Unices FreeBSD should have a larger tty field at least
as large as UT_LINESIZE (/usr/include/utmp.h). If the tty name is logged
with this size why isn't the w command reporting it? 

>How-To-Repeat:

	Use a serial console and open a getty on /dev/console and the run
the w command. It reports con and could report console like

USER     TTY      FROM              LOGIN@  IDLE WHAT
jmg      console  -                 4:50PM     - -

>Fix:

Here is a simple patch to /usr/src/usr.bin/w/w.c that uses UT_LINESIZE:

*** w.c.#orig#	Sat Mar 15 10:52:33 1997
--- w.c	Fri Jul 25 08:06:18 1997
***************
*** 235,241 ****
  		if (wcmd == 0)
  			exit (0);
  
! #define HEADER	"USER     TTY FROM              LOGIN@  IDLE WHAT\n"
  #define WUSED	(sizeof (HEADER) - sizeof ("WHAT\n"))
  		(void)printf(HEADER);
  	}
--- 235,241 ----
  		if (wcmd == 0)
  			exit (0);
  
! #define HEADER	"USER     TTY      FROM              LOGIN@  IDLE WHAT\n"
  #define WUSED	(sizeof (HEADER) - sizeof ("WHAT\n"))
  		(void)printf(HEADER);
  	}
***************
*** 338,345 ****
  			    ep->utmp.ut_host + UT_HOSTSIZE - x, x);
  			p = buf;
  		}
! 		(void)printf("%-*.*s %-3.3s %-*.*s ",
  		    UT_NAMESIZE, UT_NAMESIZE, ep->utmp.ut_name,
  		    strncmp(ep->utmp.ut_line, "tty", 3) &&
  		    strncmp(ep->utmp.ut_line, "cua", 3) ?
  		    ep->utmp.ut_line : ep->utmp.ut_line + 3,
--- 338,346 ----
  			    ep->utmp.ut_host + UT_HOSTSIZE - x, x);
  			p = buf;
  		}
! 		(void)printf("%-*.*s %-*.*s %-*.*s ",
  		    UT_NAMESIZE, UT_NAMESIZE, ep->utmp.ut_name,
+ 		    UT_LINESIZE, UT_LINESIZE,
  		    strncmp(ep->utmp.ut_line, "tty", 3) &&
  		    strncmp(ep->utmp.ut_line, "cua", 3) ?
  		    ep->utmp.ut_line : ep->utmp.ut_line + 3,



>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Sun Apr 19 11:32:08 PDT 1998 
State-Changed-Why:  
committed, thanks! 
>Unformatted:
