Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 May 1997 13:55:16 +0200 (CEST)
From:      dada@sbox.tu-graz.ac.at
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/3639: wrong times reported by ac(8)
Message-ID:  <199705201155.NAA00984@lend.tu-graz.ac.at>
Resent-Message-ID: <199705201220.FAA00574@hub.freebsd.org>

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

>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:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 20 05:20:00 PDT 1997
>Last-Modified:
>Originator:     Martin Kammerhofer
>Organization:
Graz University of Technology
>Release:        FreeBSD 2.2.2-RELEASE i386
>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);
 }
===================================================================
>Audit-Trail:
>Unformatted:



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