Date: Fri, 15 Aug 2003 17:10:43 -0400 (EDT) From: Robert Watson <rwatson@freebsd.org> To: Jonathan Chen <jonc@chen.org.nz> Cc: freebsd-stable@freebsd.org Subject: Re: odd uptime error message Message-ID: <Pine.NEB.3.96L.1030815171009.11577D-100000@fledge.watson.org> In-Reply-To: <20030814222123.GB65897@grimoire.chen.org.nz>
next in thread | previous in thread | raw e-mail | index | archive | help
Here's the patch against finger to potentially MFC as well. Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Network Associates Laboratories Index: lprint.c =================================================================== RCS file: /data/ncvs/src/usr.bin/finger/lprint.c,v retrieving revision 1.10.2.4 diff -u -r1.10.2.4 lprint.c --- lprint.c 3 Jul 2002 01:14:24 -0000 1.10.2.4 +++ lprint.c 15 Aug 2003 21:09:50 -0000 @@ -191,7 +191,8 @@ * idle time. Follow with a comma if a remote login. */ delta = gmtime(&w->idletime); - if (delta->tm_yday || delta->tm_hour || delta->tm_min) { + if (w->idletime != -1 && (delta->tm_yday || + delta->tm_hour || delta->tm_min)) { cpr += printf("%-*s idle ", maxlen - (int)strlen(w->tty) + 1, ","); if (delta->tm_yday > 0) { Index: util.c =================================================================== RCS file: /data/ncvs/src/usr.bin/finger/util.c,v retrieving revision 1.8.2.6 diff -u -r1.8.2.6 util.c --- util.c 3 Jul 2002 01:14:24 -0000 1.8.2.6 +++ util.c 15 Aug 2003 21:09:16 -0000 @@ -324,10 +324,23 @@ extern time_t now; struct stat sb; time_t touched; + int error; (void)snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_DEV, w->tty); - if (stat(tbuf, &sb) < 0) { + + error = stat(tbuf, &sb); + if (error < 0 && errno == ENOENT) { + /* + * The terminal listed is not actually a terminal (i.e., + * ":0"). This is a failure, so we'll skip printing + * out the idle time, which is non-ideal but better + * than a bogus warning and idle time. + */ + w->idletime = -1; + return; + } else if (error < 0) { warn("%s", tbuf); + w->idletime = -1; return; } touched = sb.st_atime;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.96L.1030815171009.11577D-100000>