Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Jul 2001 12:08:15 +0200 (CEST)
From:      wolfgang@lyxys.ka.sub.org
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/28789: /usr/bin/last does not filter for uucp connects
Message-ID:  <m15Ip0Z-003pVhC@lyxys.ka.sub.org>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?m15Ip0Z-003pVhC>