diff options
author | jkoshy <jkoshy@FreeBSD.org> | 1998-05-14 10:13:24 +0000 |
---|---|---|
committer | jkoshy <jkoshy@FreeBSD.org> | 1998-05-14 10:13:24 +0000 |
commit | b964b328b659cc6f4e0e38cf7680556c10c828d5 (patch) | |
tree | ab501076fb9131edddfc85239ad94eac833d68be /usr.bin/w/w.c | |
parent | c7a5604130eade6e287042a3183d9c4833978cdd (diff) | |
download | FreeBSD-src-b964b328b659cc6f4e0e38cf7680556c10c828d5.zip FreeBSD-src-b964b328b659cc6f4e0e38cf7680556c10c828d5.tar.gz |
Allow `w' to treat a corrupted "utmp" as a non fatal error.
PR: bin/2832
Diffstat (limited to 'usr.bin/w/w.c')
-rw-r--r-- | usr.bin/w/w.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index 12ca2b1..9ef076f 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)w.c 8.4 (Berkeley) 4/16/94"; #endif static const char rcsid[] = - "$Id: w.c,v 1.24 1997/10/13 15:17:03 ache Exp $"; + "$Id: w.c,v 1.25 1998/04/19 18:32:01 phk Exp $"; #endif /* not lint */ /* @@ -209,6 +209,8 @@ main(argc, argv) for (nusers = 0; fread(&utmp, sizeof(utmp), 1, ut);) { if (utmp.ut_name[0] == '\0') continue; + if (!(stp = ttystat(utmp.ut_line))) /* corrupted record */ + continue; ++nusers; if (wcmd == 0 || (sel_user && strncmp(utmp.ut_name, sel_user, UT_NAMESIZE) != 0)) @@ -218,7 +220,6 @@ main(argc, argv) *nextp = ep; nextp = &(ep->next); memmove(&(ep->utmp), &utmp, sizeof(struct utmp)); - stp = ttystat(ep->utmp.ut_line); ep->tdev = stp->st_rdev; #ifdef CPU_CONSDEV /* @@ -476,8 +477,10 @@ ttystat(line) char ttybuf[MAXPATHLEN]; (void)snprintf(ttybuf, sizeof(ttybuf), "%s/%s", _PATH_DEV, line); - if (stat(ttybuf, &sb)) - err(1, "%s", ttybuf); + if (stat(ttybuf, &sb)) { + warn("%s", ttybuf); + return NULL; + } return (&sb); } |