aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/wall
diff options
context:
space:
mode:
authorOlivier Houchard <cognet@FreeBSD.org>2006-02-21 13:01:00 +0000
committerOlivier Houchard <cognet@FreeBSD.org>2006-02-21 13:01:00 +0000
commitb457a3e19cd7c0d83dae9681c658dab8317da8df (patch)
treec5c9433b584c538f5c632cb200b65fd6c24cd3ea /usr.bin/wall
parentc15ff0bc7bccdc23c1124363a8b24f4393b9e3b0 (diff)
Notes
Diffstat (limited to 'usr.bin/wall')
-rw-r--r--usr.bin/wall/wall.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/usr.bin/wall/wall.c b/usr.bin/wall/wall.c
index 35d6463cdd91..1a1d2a383732 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));