From owner-freebsd-bugs Sat Jul 7 3:20:13 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 3888637B40B for ; Sat, 7 Jul 2001 03:20:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.3/8.11.3) id f67AK1d40958; Sat, 7 Jul 2001 03:20:01 -0700 (PDT) (envelope-from gnats) Received: from subnet.sub.net (subnet.sub.net [212.227.14.21]) by hub.freebsd.org (Postfix) with ESMTP id 31C9E37B405 for ; Sat, 7 Jul 2001 03:10:44 -0700 (PDT) (envelope-from wolfgang@lyxys.ka.sub.org) Received: from lyxys.ka.sub.org (uucp@localhost) by subnet.sub.net (8.8.8/8.8.8/1.2subnet-linux) with bsmtp id MAA17051 for FreeBSD-gnats-submit@freebsd.org; Sat, 7 Jul 2001 12:10:38 +0200 Received: from localhost (3804 bytes) by lyxys.ka.sub.org via sendmail with P:stdio/R:smart_host/T:inet_uusmtp (sender: ) (ident using unix) id for ; Sat, 7 Jul 2001 12:08:15 +0200 (CEST) (Smail-3.2.0.111 2000-Feb-17 #1 built 2000-Aug-23) Message-Id: Date: Sat, 7 Jul 2001 12:08:15 +0200 (CEST) From: wolfgang@lyxys.ka.sub.org Reply-To: wolfgang@lyxys.ka.sub.org To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/28789: /usr/bin/last does not filter for uucp connects Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 28789 >Category: bin >Synopsis: /usr/bin/last does not filter for uucp connects >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Jul 07 03:20:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Wolfgang Zenker >Release: FreeBSD 4.3-STABLE i386 >Organization: >Environment: System: FreeBSD vectra.lyx 4.3-STABLE FreeBSD 4.3-STABLE #8: Mon Jun 4 21:58:24 CEST 2001 wolfgang@vectra.lyx:/var/obj/usr/src/sys/VECTRA i386 >Description: /usr/bin/last has an option "-t tty" that allows to filter only entries related to the specified tty. However this does not work with pseudo tty names like "uucp" or "ftpd", because the tty field of the utmp-entry contains a combination of the pseudo tty name and the (non-displayed) process-id. >How-To-Repeat: >Fix: Suggested fix is to introduce a new option "-T ttytype" to /usr/bin/last. This option would allow to filter for entries with tty name fields starting with the specified string. Suggested implementation is attached as diff to last.c and last.1, I hope it is not garbled by send-pr. *** last.c.org Mon Mar 12 02:41:21 2001 --- last.c Sat Jul 7 11:09:54 2001 *************** *** 69,74 **** --- 69,75 ---- #define HOST_TYPE -2 #define TTY_TYPE -3 #define USER_TYPE -4 + #define TTYG_TYPE -5 int type; /* type of arg */ struct arg *next; /* linked list pointer */ } ARG; *************** *** 99,105 **** usage(void) { (void)fprintf(stderr, ! "usage: last [-#] [-f file] [-h hostname] [-t tty] [-s|w] [user ...]\n"); exit(1); } --- 100,106 ---- usage(void) { (void)fprintf(stderr, ! "usage: last [-#] [-f file] [-h hostname] [-t tty] [-T ttytype] [-s|w] [user ...]\n"); exit(1); } *************** *** 114,120 **** (void) setlocale(LC_TIME, ""); maxrec = -1; ! while ((ch = getopt(argc, argv, "0123456789f:h:st:w")) != -1) switch (ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': --- 115,121 ---- (void) setlocale(LC_TIME, ""); maxrec = -1; ! while ((ch = getopt(argc, argv, "0123456789f:h:st:wT:")) != -1) switch (ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': *************** *** 148,153 **** --- 149,157 ---- case 'w': width = 8; break; + case 'T': + addarg(TTYG_TYPE, ttyconv(optarg)); + break; case '?': default: usage(); *************** *** 349,354 **** --- 353,362 ---- break; case USER_TYPE: if (!strncmp(step->name, bp->ut_name, UT_NAMESIZE)) + return (YES); + break; + case TTYG_TYPE: + if (!strncmp(step->name, bp->ut_line, strlen(step->name))) return (YES); break; } *** last.1.org Thu Dec 14 10:54:46 2000 --- last.1 Sat Jul 7 11:12:30 2001 *************** *** 45,50 **** --- 45,51 ---- .Op Fl h Ar host .Op Fl s .Op Fl t Ar tty + .Op Fl T Ar ttytype .Op Fl w .Op user ... .Sh DESCRIPTION *************** *** 52,57 **** --- 53,59 ---- will list the sessions of specified .Ar users , .Ar ttys , + .Ar ttytypes , and .Ar hosts , in reverse time order. Each line of output contains *************** *** 87,92 **** --- 89,102 ---- is equivalent to .Dq Li "last -t tty03" . + .It Fl T Ar ttytype + Specify the + .Ar tty type . + Tty type in this context is the start of the tty name, so you can ask for + groups of ttys, e.g., + .Dq Li "last -T cua" . + This is especially usefull for pseudo tty names like + .Dq "uucp" . .It Fl w Widen the duration field to show seconds, as well as the default days, hours and minutes. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message