Subject: bin/28185: w command broken when user specified
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <marcotte@panix.com>
List: netbsd-bugs
Date: 11/10/2004 23:30:00
>Number: 28185
>Category: bin
>Synopsis: w command broken when user specified
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Nov 10 23:30:00 +0000 2004
>Originator: Brian Marcotte
>Release: NetBSD 2.0_RC4
>Organization:
panix.com
>Environment:
System: NetBSD panix5.panix.com 2.0_RC4 NetBSD 2.0_RC4 (PANIX-USER) #0: Sat Nov 6 19:39:39 EST 2004 root@trinity.nyc.access.net:/devel/netbsd/release-2.0-20041022/src/sys/arch/i386/compile/PANIX-USER i386
Userland matches kernel
Architecture: i386
Machine: i386
>Description:
The "w" command doesn't work correctly when given a username on
the command line:
>How-To-Repeat:
> w -n alexis
6:26PM up 3 days, 18:55, 37 users, load averages: 0.73, 1.31, 1.06
USER TTY FROM LOGIN@ IDLE WHAT
abc2 pF 166.84.1.1 6:15PM 0 trn
alexis ph 166.84.1.1 3:46AM 6 -zsh
akklwws qb 166.84.1.1 10:21AM 1 -tcsh
ann qd 166.84.1.1 Tue05PM 1:11 tail -40 -f .p
abc2 qh 166.84.1.1 Tue09AM 3:12 -bash
abc2 qn 166.84.1.1 Tue09AM 33:05 -bash
ajqkhjwh qr 166.84.1.1 12:25PM 3:07 slrn
Note that the usernames found all begin with the letter "a".
>Fix:
--- /devel/netbsd/release-2.0-20041022/src/usr.bin/w/w.c Fri Jan 2 20:18:14 2004
+++ /users/marcotte/w/w.c Wed Nov 10 18:22:03 2004
@@ -209,8 +209,9 @@
continue;
++nusers;
if (sel_user &&
- strncmp(utx->ut_name, sel_user, sizeof(utx->ut_name) != 0))
+ strncmp(utx->ut_name, sel_user, sizeof(utx->ut_name)) != 0)
continue;
+
if ((ep = calloc(1, sizeof(struct entry))) == NULL)
err(1, NULL);
(void)memcpy(ep->name, utx->ut_name, sizeof(utx->ut_name));
@@ -240,7 +241,7 @@
continue;
if (sel_user &&
- strncmp(ut->ut_name, sel_user, sizeof(ut->ut_name) != 0))
+ strncmp(ut->ut_name, sel_user, sizeof(ut->ut_name)) != 0)
continue;
/* Don't process entries that we have utmpx for */