From 06cfdceb6c8993e73b4daaf984e0785ea75ddc34 Mon Sep 17 00:00:00 2001 From: cognet Date: Tue, 21 Feb 2006 13:01:00 +0000 Subject: In wall and who, check that the utmp entry isn't stalled, as it is done in w. Apparently with the new pts code stalled entries are printed, when they are not with the BSD ptys. Submitted by: Michal Mertl --- usr.bin/wall/wall.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'usr.bin/wall') diff --git a/usr.bin/wall/wall.c b/usr.bin/wall/wall.c index 35d6463..1a1d2a3 100644 --- a/usr.bin/wall/wall.c +++ b/usr.bin/wall/wall.c @@ -81,6 +81,19 @@ int nobanner; int mbufsize; char *mbuf; +static int +ttystat(char *line, int sz) +{ + struct stat sb; + char ttybuf[MAXPATHLEN]; + + (void)snprintf(ttybuf, sizeof(ttybuf), "%s%.*s", _PATH_DEV, sz, line); + if (stat(ttybuf, &sb) == 0) { + return (0); + } else + return (-1); +} + int main(int argc, char *argv[]) { @@ -140,6 +153,8 @@ main(int argc, char *argv[]) while (fread((char *)&utmp, sizeof(utmp), 1, fp) == 1) { if (!utmp.ut_name[0]) continue; + if (ttystat(utmp.ut_line, UT_LINESIZE) != 0) + continue; if (grouplist) { ingroup = 0; strlcpy(username, utmp.ut_name, sizeof(utmp.ut_name)); -- cgit v1.1