Date: Tue, 13 Apr 1999 19:54:17 GMT From: James Howard <howardjp@byzantine.student.umd.edu> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/11121: w(1) cannot handle more than one user on command line Message-ID: <199904131954.TAA03155@byzantine.student.umd.edu>
index | next in thread | raw e-mail
>Number: 11121
>Category: bin
>Synopsis: w(1) cannot handle more than one user on command line
>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: Tue Apr 13 16:50:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator: James Howard
>Release: FreeBSD 3.1-RELEASE i386
>Organization:
University of Maryland
>Environment:
FreeBSD byzantine.student.umd.edu 3.1-RELEASE FreeBSD 3.1-RELEASE #0: Mon Feb 15 11:08:08 GMT 1999 jkh@usw3.freebsd.org:/usr/src/sys/compile/GENERIC i386
>Description:
For years, I have wanted w(1) to be able to handle a command line with
multiple user names listed. When presented with multiple users, it
will only present information on the first.
>How-To-Repeat:
% w user1 user2
>Fix:
This isn't very pretty, but it does work. Apply this patch to
/usr/src/usr.bin/w and it will update w.c and w.1.
diff -c -r /usr/src/usr.bin/w/w.1 w/w.1
*** /usr/src/usr.bin/w/w.1 Sun Mar 22 17:39:08 1998
--- w/w.1 Tue Apr 13 17:34:05 1999
***************
*** 43,49 ****
.Op Fl dhin
.Op Fl M Ar core
.Op Fl N Ar system
! .Op Ar user
.Sh DESCRIPTION
The
.Nm
--- 43,49 ----
.Op Fl dhin
.Op Fl M Ar core
.Op Fl N Ar system
! .Op Ar user ...
.Sh DESCRIPTION
The
.Nm
***************
*** 83,91 ****
interprets addresses and attempts to display them symbolically).
.El
.Pp
! If a
.Ar user
! name is specified, the output is restricted to that user.
.Sh FILES
.Bl -tag -width /var/run/utmp -compact
.It Pa /var/run/utmp
--- 83,91 ----
interprets addresses and attempts to display them symbolically).
.El
.Pp
! If
.Ar user
! names are specified, the output is restricted to those users.
.Sh FILES
.Bl -tag -width /var/run/utmp -compact
.It Pa /var/run/utmp
diff -c -r /usr/src/usr.bin/w/w.c w/w.c
*** /usr/src/usr.bin/w/w.c Sun Jan 10 15:28:37 1999
--- w/w.c Tue Apr 13 18:06:25 1999
***************
*** 98,104 ****
int nflag; /* true if -n flag: don't convert addrs */
int dflag; /* true if -d flag: output debug info */
int sortidle; /* sort by idle time */
- char *sel_user; /* login of particular user selected */
char domain[MAXHOSTNAMELEN];
/*
--- 98,103 ----
***************
*** 135,141 ****
FILE *ut;
u_long l;
size_t arglen;
! int ch, i, nentries, nusers, wcmd, longidle;
char *memf, *nlistf, *p, *x;
char buf[MAXHOSTNAMELEN], errbuf[256];
--- 134,140 ----
FILE *ut;
u_long l;
size_t arglen;
! int ch, i, nentries, nusers, wcmd, longidle, uflag;
char *memf, *nlistf, *p, *x;
char buf[MAXHOSTNAMELEN], errbuf[256];
***************
*** 201,218 ****
if ((ut = fopen(_PATH_UTMP, "r")) == NULL)
err(1, "%s", _PATH_UTMP);
- if (*argv)
- sel_user = *argv;
-
for (nusers = 0; fread(&utmp, sizeof(utmp), 1, ut);) {
if (utmp.ut_name[0] == '\0')
continue;
if (!(stp = ttystat(utmp.ut_line))) /* corrupted record */
continue;
++nusers;
! if (wcmd == 0 || (sel_user &&
! strncmp(utmp.ut_name, sel_user, UT_NAMESIZE) != 0))
! continue;
if ((ep = calloc(1, sizeof(struct entry))) == NULL)
errx(1, "calloc");
*nextp = ep;
--- 200,222 ----
if ((ut = fopen(_PATH_UTMP, "r")) == NULL)
err(1, "%s", _PATH_UTMP);
for (nusers = 0; fread(&utmp, sizeof(utmp), 1, ut);) {
if (utmp.ut_name[0] == '\0')
continue;
if (!(stp = ttystat(utmp.ut_line))) /* corrupted record */
continue;
++nusers;
! if(*argv)
! uflag = 0;
! else
! uflag = 1;
! for (i = 0; i < argc; i++) {
! if (wcmd == 0 || (argv[i] &&
! strncmp(utmp.ut_name, argv[i], UT_NAMESIZE) == 0))
! uflag = 1;
! }
! if(!uflag)
! continue;
if ((ep = calloc(1, sizeof(struct entry))) == NULL)
errx(1, "calloc");
*nextp = ep;
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199904131954.TAA03155>
