From dada@lend.tu-graz.ac.at  Tue May 20 05:15:58 1997
Received: from fcggsg07.icg.tu-graz.ac.at ([129.27.201.16])
          by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id FAA00329
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 20 May 1997 05:11:31 -0700 (PDT)
Received: from lend.tu-graz.ac.at (isdn072.tu-graz.ac.at [129.27.240.72])
          by fcggsg07.icg.tu-graz.ac.at (8.8.4/8.8.4) with ESMTP
	  id OAA12660 for <FreeBSD-gnats-submit@freebsd.org>; Tue, 20 May 1997 14:04:26 +0200 (MDT)
Received: (from dada@localhost)
	by lend.tu-graz.ac.at (8.8.5/8.8.5) id NAA00984;
	Tue, 20 May 1997 13:55:16 +0200 (CEST)
Message-Id: <199705201155.NAA00984@lend.tu-graz.ac.at>
Date: Tue, 20 May 1997 13:55:16 +0200 (CEST)
From: dada@sbox.tu-graz.ac.at
Reply-To: dada@sbox.tu-graz.ac.at
To: FreeBSD-gnats-submit@freebsd.org
Subject: wrong times reported by ac(8)
X-Send-Pr-Version: 3.2

>Number:         3639
>Category:       bin
>Synopsis:       ac doesn't know about FreeBSD's pty names
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 20 05:20:00 PDT 1997
>Closed-Date:    Fri Jul 3 02:07:35 PDT 1998
>Last-Modified:  Fri Jul  3 02:08:27 PDT 1998
>Originator:     Martin Kammerhofer
>Release:        FreeBSD 2.2.2-RELEASE i386
>Organization:
Graz University of Technology
>Environment:
	FreeBSD, AFAIK all releases

>Description:

	ac(8) (a connect time accounting utility) reports wrong times,
	often 0.0
	Reason: The program doesn't account for logins on pseudo-ttys (ptys)
			from local, i.e. without a host-entry in wtmp.
			The code to decide what's a pty is not corrected for
			FreeBSD's pty naming conventions.

>How-To-Repeat:

>Fix:
	
	I supply a patch which adds a '-l' option to account local logins on
	ptys and makes ac(8) aware of FreeBSD pty names.


Index: ac.c
===================================================================
RCS file: /home/dada/cvsroot/src/ac.c,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- ac.c	1997/02/11 07:49:21	1.1
+++ ac.c	1997/05/20 11:39:19	1.3
@@ -11,10 +11,15 @@
  *      2/ that any changes to this code are clearly commented
  *      as such so that the author does not get blamed for bugs
  *      other than his own.
+ * 
+ *	Changes 1997 by M.Kammerhofer:
+ *	Added a -l flag to account for login records with local pseudo-ttys
+ *		these are ignored by default.
+ *	Corrected for FreeBSD pty names, they're a bit non-standard.
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: ac.c,v 1.1 1997/02/11 07:49:21 dada Exp $";
+static char rcsid[] = "$Id: ac.c,v 1.3 1997/05/20 11:39:19 dada Exp $";
 #endif
 
 #include <sys/types.h>
@@ -76,6 +81,8 @@
 #define	AC_P	4				/* per-user totals */
 #define	AC_U	8				/* specified users only */
 #define	AC_T	16				/* specified ttys only */
+/* added by M.Kammerhofer */
+#define AC_L	32				/* don't ign. local ptys */
 
 #ifdef DEBUG
 static int Debug = 0;
@@ -229,7 +236,7 @@
 	(void) setlocale(LC_TIME, "");
 
 	fp = NULL;
-	while ((c = getopt(argc, argv, "Dc:dpt:w:")) != EOF) {
+	while ((c = getopt(argc, argv, "Dc:dpt:w:l")) != EOF) {
 		switch (c) {
 #ifdef DEBUG
 		case 'D':
@@ -246,6 +253,9 @@
 		case 'd':
 			Flags |= AC_D;
 			break;
+		case 'l':
+			Flags |= AC_L;
+			break;
 		case 'p':
 			Flags |= AC_P;
 			break;
@@ -507,8 +517,13 @@
 			 */
 			if (*usr.ut_name) {
 				if (strncmp(usr.ut_line, "tty", 3) != 0 ||
+#ifdef __FreeBSD__
+				    strchr("pqrsPQRS", usr.ut_line[3]) == 0 ||
+#else
 				    strchr("pqrstuvwxy", usr.ut_line[3]) == 0 ||
-				    *usr.ut_host != '\0')
+#endif
+				    *usr.ut_host != '\0' ||
+				    Flags & AC_L)
 					head = log_in(head, &usr);
 			} else
 				head = log_out(head, &usr);
@@ -552,9 +567,9 @@
 {
 	(void)fprintf(stderr,
 #ifdef CONSOLE_TTY
-	    "ac [-dp] [-c console] [-t tty] [-w wtmp] [users ...]\n");
+	    "ac [-dpl] [-c console] [-t tty] [-w wtmp] [users ...]\n");
 #else
-	    "ac [-dp] [-t tty] [-w wtmp] [users ...]\n");
+	    "ac [-dpl] [-t tty] [-w wtmp] [users ...]\n");
 #endif
 	exit(1);
 }
===================================================================
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Fri Jul 3 02:07:35 PDT 1998 
State-Changed-Why:  
As part of our PR audition campaign, this PR has been closed.  I belive 
this problem have been fixed although this PR has not been referenced 
in the commit message.   

We apologize for late response to this PR. 
>Unformatted:
