summaryrefslogtreecommitdiffstats
path: root/usr.bin/who/who.c
diff options
context:
space:
mode:
authorcognet <cognet@FreeBSD.org>2006-02-21 13:01:00 +0000
committercognet <cognet@FreeBSD.org>2006-02-21 13:01:00 +0000
commit06cfdceb6c8993e73b4daaf984e0785ea75ddc34 (patch)
treec5c9433b584c538f5c632cb200b65fd6c24cd3ea /usr.bin/who/who.c
parent895ec9cce0dbdfb3780e9702d4728c5d5227d771 (diff)
downloadFreeBSD-src-06cfdceb6c8993e73b4daaf984e0785ea75ddc34.zip
FreeBSD-src-06cfdceb6c8993e73b4daaf984e0785ea75ddc34.tar.gz
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 <mime at traveller dot cz>
Diffstat (limited to 'usr.bin/who/who.c')
-rw-r--r--usr.bin/who/who.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/usr.bin/who/who.c b/usr.bin/who/who.c
index 27b6896..f94fcdb 100644
--- a/usr.bin/who/who.c
+++ b/usr.bin/who/who.c
@@ -27,6 +27,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/param.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
@@ -203,14 +204,31 @@ row(struct utmp *ut)
putchar('\n');
}
+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);
+}
+
static void
process_utmp(FILE *fp)
{
struct utmp ut;
- while (fread(&ut, sizeof(ut), 1, fp) == 1)
- if (*ut.ut_name != '\0')
- row(&ut);
+ while (fread(&ut, sizeof(ut), 1, fp) == 1) {
+ if (*ut.ut_name == '\0')
+ continue;
+ if (ttystat(ut.ut_line, UT_LINESIZE) != 0)
+ continue;
+ row(&ut);
+ }
}
static void
OpenPOWER on IntegriCloud