odd uptime error message
Robert Watson
rwatson at freebsd.org
Fri Aug 15 14:11:20 PDT 2003
Here's the patch against finger to potentially MFC as well.
Robert N M Watson FreeBSD Core Team, TrustedBSD Projects
robert at 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;
More information about the freebsd-stable
mailing list