diff options
author | Robert Watson <rwatson@FreeBSD.org> | 2003-04-02 20:22:29 +0000 |
---|---|---|
committer | Robert Watson <rwatson@FreeBSD.org> | 2003-04-02 20:22:29 +0000 |
commit | 7d7d429762fce001061c650b0c5f1935e21918c3 (patch) | |
tree | f72c83dc9edbf32b99a0125f281f577ae7fca0c8 /usr.bin/finger | |
parent | 70861b840c8700b2632cda3ceb3a32d020f286be (diff) |
Notes
Diffstat (limited to 'usr.bin/finger')
-rw-r--r-- | usr.bin/finger/lprint.c | 3 | ||||
-rw-r--r-- | usr.bin/finger/sprint.c | 5 | ||||
-rw-r--r-- | usr.bin/finger/util.c | 15 |
3 files changed, 21 insertions, 2 deletions
diff --git a/usr.bin/finger/lprint.c b/usr.bin/finger/lprint.c index 16a10a57b9b3..d74b21e781ea 100644 --- a/usr.bin/finger/lprint.c +++ b/usr.bin/finger/lprint.c @@ -189,7 +189,8 @@ no_gecos: * 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) { diff --git a/usr.bin/finger/sprint.c b/usr.bin/finger/sprint.c index 396c86e39dd5..51a19190b01f 100644 --- a/usr.bin/finger/sprint.c +++ b/usr.bin/finger/sprint.c @@ -167,6 +167,11 @@ stimeprint(WHERE *w) { struct tm *delta; + if (w->idletime == -1) { + (void)printf(" "); + return; + } + delta = gmtime(&w->idletime); if (!delta->tm_yday) if (!delta->tm_hour) diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c index 229d58a9abce..3ac5a068331c 100644 --- a/usr.bin/finger/util.c +++ b/usr.bin/finger/util.c @@ -314,10 +314,23 @@ find_idle_and_ttywrite(WHERE *w) { 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; |