From owner-freebsd-bugs Thu Aug 5 2:10:25 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 30CA715015 for ; Thu, 5 Aug 1999 02:10:22 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id CAA05301; Thu, 5 Aug 1999 02:10:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from rins.st.ryukoku.ac.jp (rins.st.ryukoku.ac.jp [133.83.4.1]) by hub.freebsd.org (Postfix) with ESMTP id 69F9314E33 for ; Thu, 5 Aug 1999 02:07:51 -0700 (PDT) (envelope-from kjm@ideon.st.ryukoku.ac.jp) Received: from ideon.st.ryukoku.ac.jp (ideon.st.ryukoku.ac.jp [133.83.36.5]) by rins.st.ryukoku.ac.jp (8.9.3+3.2W/3.7W/RINS-1.9.6-NOSPAM) with ESMTP id SAA03882 for ; Thu, 5 Aug 1999 18:07:02 +0900 (JST) Received: (from kjm@localhost) by ideon.st.ryukoku.ac.jp (8.9.3/3.7W/kjm-19990628) id SAA08563; Thu, 5 Aug 1999 18:07:01 +0900 (JST) Message-Id: <199908050907.SAA08563@ideon.st.ryukoku.ac.jp> Date: Thu, 5 Aug 1999 18:07:01 +0900 (JST) From: kjm@rins.ryukoku.ac.jp (KOJIMA Hajime) Reply-To: kjm@rins.ryukoku.ac.jp To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/12982: last command -y option support patch Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 12982 >Category: bin >Synopsis: last does not support -y option. >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: Thu Aug 5 02:10:00 PDT 1999 >Closed-Date: >Last-Modified: >Originator: KOJIMA Hajime >Release: FreeBSD 3.2-RELEASE i386 >Organization: Ryukoku University >Environment: CPU: Celeron 466MHz Memory: 128MB >Description: FreeBSD's last command does not support -y option. GNU version of last command (in acct package) support -y option, and its useful. >How-To-Repeat: % last -y last: illegal option -- y usage: last [-#] [-f file] [-h hostname] [-t tty] [-s|w] [user ...] >Fix: Apply this patch. --- last.1.dist Thu Aug 5 17:37:58 1999 +++ last.1 Thu Aug 5 17:41:08 1999 @@ -45,6 +45,7 @@ .Op Fl s .Op Fl t Ar tty .Op Fl w +.Op Fl y .Op user ... .Sh DESCRIPTION .Nm Last @@ -89,6 +90,8 @@ .It Fl w Widen the duration field to show seconds, as well as the default days, hours and minutes. +.It Fl y +Report the duration of the login session with year. .El .Pp If --- last.c.dist Thu Aug 5 17:18:37 1999 +++ last.c Thu Aug 5 18:04:12 1999 @@ -85,6 +85,8 @@ static char *file = _PATH_WTMP; /* wtmp file */ static int sflag = 0; /* show delta in seconds */ static int width = 5; /* show seconds in delta */ +static int showyear = NO; /* show year */ +#define YEAR_SIZE 4 /* Y10K BUG HERE: to fix, change 4 to 5 */ void addarg __P((int, char *)); void hostconv __P((char *)); @@ -97,7 +99,7 @@ usage(void) { (void)fprintf(stderr, - "usage: last [-#] [-f file] [-h hostname] [-t tty] [-s|w] [user ...]\n"); + "usage: last [-#] [-f file] [-h hostname] [-t tty] [-s|w] [-y] [user ...]\n"); exit(1); } @@ -114,7 +116,7 @@ (void) setlocale(LC_TIME, ""); maxrec = -1; - while ((ch = getopt(argc, argv, "0123456789f:h:st:w")) != -1) + while ((ch = getopt(argc, argv, "0123456789f:h:st:wy")) != -1) switch (ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': @@ -148,6 +150,9 @@ case 'w': width = 8; break; + case 'y': + showyear = YES; + break; case '?': default: usage(); @@ -240,11 +245,21 @@ if (want(bp)) { tm = localtime(&bp->ut_time); (void) strftime(ct, sizeof(ct), "%c", tm); - printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s \n", - UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, - UT_LINESIZE, UT_LINESIZE, bp->ut_line, - UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host, - ct, ct + 11); + if (showyear) { + printf("%-*.*s %-*.*s %-*.*s %10.10s %*.*s %5.5s \n", + UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, + UT_LINESIZE, UT_LINESIZE, bp->ut_line, + UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host, + ct, + YEAR_SIZE, YEAR_SIZE, ct + 20, + ct + 11); + } else { + printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s \n", + UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, + UT_LINESIZE, UT_LINESIZE, bp->ut_line, + UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host, + ct, ct + 11); + } if (maxrec && !--maxrec) return; } @@ -278,11 +293,21 @@ bp->ut_line[4] = '\0'; tm = localtime(&bp->ut_time); (void) strftime(ct, sizeof(ct), "%c", tm); - printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s ", - UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, - UT_LINESIZE, UT_LINESIZE, bp->ut_line, - UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host, - ct, ct + 11); + if (showyear) { + printf("%-*.*s %-*.*s %-*.*s %10.10s %*.*s %5.5s ", + UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, + UT_LINESIZE, UT_LINESIZE, bp->ut_line, + UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host, + ct, + YEAR_SIZE, YEAR_SIZE, ct + 20, + ct + 11); + } else { + printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s ", + UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, + UT_LINESIZE, UT_LINESIZE, bp->ut_line, + UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host, + ct, ct + 11); + } if (!tt->logout) puts(" still logged in"); else { >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message