Date: Mon, 14 Jan 2002 17:24:54 +0200 From: Ruslan Ermilov <ru@FreeBSD.ORG> To: Giorgos Keramidas <keramida@ceid.upatras.gr> Cc: audit@FreeBSD.ORG Subject: Re: last with -y option Message-ID: <20020114172454.G21333@sunbay.com> In-Reply-To: <20020111232631.GA66629@hades.hell.gr> References: <20020111232631.GA66629@hades.hell.gr>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Jan 12, 2002 at 01:26:31AM +0200, Giorgos Keramidas wrote:
> The patch that was sent in PR bin/12982 does not apply to the
> usr.bin/last (probably because our last was modified for WARNS=2 after
> the patch was submitted), but I liked the idea that it describes.
>
> The attached patch adds a -y option to last that will print the year
> too when listing wtmp records. It also removes a few EOL whitespaces
> that I found while reading the last.c source.
>
> If this does not break any standards, and you don't think that it
> breaks last(1) in some way, I'll have to find myself an src/ committer
> to take care of this PR :-)
>
There're two functional and style bugs in your patch, see below.
> Index: last.1
[...]
> @@ -162,4 +163,6 @@
> Widen the duration field to show seconds, as well as the
> default days, hours and minutes.
> +.It Fl w
> +Report years too in the login session duration.
> .El
> .Pp
This should yield -y not -w.
> Index: last.c
[...]
> @@ -246,13 +250,22 @@
> /*
> * don't print shutdown/reboot entries
> - * unless flagged for
> - */
> + * unless flagged for
> + */
Please don't commit unrelated whitespace changes together with functional
ones, commit them seperately.
> if (!snaptime && want(bp)) {
> t = int_to_time(bp->ut_time);
> tm = localtime(&t);
> - (void) strftime(ct, sizeof(ct),
> - d_first ? "%a %e %b %R" :
> - "%a %b %e %R",
> - tm);
> + if (yflag) {
> + (void) strftime(ct, sizeof(ct),
> + d_first
> + ? "%a %e %b %Y %R"
> + : "%a %b %e %Y %R",
> + tm);
> + } else {
> + (void) strftime(ct, sizeof(ct),
> + d_first
> + ? "%a %e %b %Y %R"
> + : "%a %b %e %Y %R",
> + tm);
> + }
These two sub-blocks in the "if" clause are identical, meaning you have
year printed unconditionally for startup/shutdown events.
> @@ -293,5 +315,5 @@
> if (!strncmp(tt->tty, bp->ut_line, UT_LINESIZE))
> break;
> -
> +
> if (tt == NULL) {
> /* add new one */
Garbage.
> @@ -303,5 +325,5 @@
> LIST_INSERT_HEAD(&ttylist, tt, list);
> }
> -
> +
> /*
> * print record if not in snapshot mode and wanted
Ditto.
> @@ -346,5 +375,5 @@
> delta = tt->logout - bp->ut_time;
> if ( sflag ) {
> - printf(" (%8ld)\n",
> + printf(" (%8ld)\n",
> (long)delta);
> } else {
Ditto.
Cheers,
--
Ruslan Ermilov Oracle Developer/DBA,
ru@sunbay.com Sunbay Software AG,
ru@FreeBSD.org FreeBSD committer,
+380.652.512.251 Simferopol, Ukraine
http://www.FreeBSD.org The Power To Serve
http://www.oracle.com Enabling The Information Age
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020114172454.G21333>
