From owner-freebsd-bugs Tue May 20 05:20:03 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id FAA00590 for bugs-outgoing; Tue, 20 May 1997 05:20:03 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.5/8.8.5) id FAA00574; Tue, 20 May 1997 05:20:01 -0700 (PDT) Resent-Date: Tue, 20 May 1997 05:20:01 -0700 (PDT) Resent-Message-Id: <199705201220.FAA00574@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, dada@sbox.tu-graz.ac.at 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 ; 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 ; 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 X-Send-Pr-Version: 3.2 Subject: bin/3639: wrong times reported by ac(8) Sender: owner-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >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 @@ -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: