bin/57089: "w" does not honor the -n option

Kirk Strauser kirk at strauser.com
Mon Sep 22 08:00:31 PDT 2003


>Number:         57089
>Category:       bin
>Synopsis:       "w" does not honor the -n option
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 22 08:00:28 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Kirk Strauser <kirk at strauser.com>
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
The Strauser Group
>Environment:
System: FreeBSD kanga.honeypot.net 5.1-CURRENT FreeBSD 5.1-CURRENT #0: Fri Sep 19 14:51:41 CDT 2003 root at kanga.honeypot.net:/usr/obj/usr/src/sys/KANGA i386


	
>Description:
w's -n option is supposed to prevent resolution of the network addresses
that users are connecting from.  On my 5.1-CURRENT system, built on
2003-09-19, this is not the case.

w's normal output:

    kirk at kanga:~$ w
     9:29AM  up 2 days, 17:04, 2 users, load averages: 0.42, 0.61, 0.68
    USER             TTY      FROM              LOGIN@  IDLE WHAT
    kirk             p0       pooh              9:22AM     - w
    kirk             p1       pooh              9:23AM     - vim /tmp/pf.eAAIb48f

With the -n option to prevent address resolution:

    kirk at kanga:~$ w -n
     9:29AM  up 2 days, 17:04, 2 users, load averages: 0.42, 0.61, 0.68
    USER             TTY      FROM              LOGIN@  IDLE WHAT
    kirk             p0       pooh              9:22AM     - w -n
    kirk             p1       pooh              9:23AM     - vim /tmp/pf.eAAIb48f

	
>How-To-Repeat:
The problem is trivially repeatable; just re-run "w -n".
	
>Fix:
I don't have a lot of experience with wtmp, but it looks like the default
value for the host field is set by these lines:

    strncpy(host_buf, ep->utmp.ut_host, UT_HOSTSIZE);
    p = *host_buf ? host_buf : "-";

If the "nflag" variable (set if "-n" is specified at the command line) is
true, then "p" is reset to the value of the resolved address.

However, it seems that the "ep->utmp.ut_host" field is also a string
containing the resolved hostname; "p" is never assigned anything that looks
like a numeric IP.

	


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list