Subject: bin/26168: wall tries to write to non tty lines
To: None <>
From: Martin Husemann <>
List: netbsd-bugs
Date: 07/05/2004 19:34:12
>Number:         26168
>Category:       bin
>Synopsis:       wall tries to write to non tty lines
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 05 17:35:00 UTC 2004
>Originator:     Martin Husemann
>Release:        NetBSD 2.0G
System: NetBSD 2.0G NetBSD 2.0G (PORTER) #5: Sun Jul 4 18:09:04 CEST 2004 i386
Architecture: i386
Machine: i386

Some X login managers, like gdm, create an utmpx entry with the $DISPLAY as
the "line" entry. Details have been discussed in PR pkg/25879.

When wall(1) is invoked (for example from shutdown) it tries to write to such
devices - and fails. Unfortunately it complains verbosely about the failure.
The attached patch makes it skip the "illegal" line silently.


Run gdm, log in, run "shutdown -r now".

Index: wall.c
RCS file: /cvsroot/src/usr.bin/wall/wall.c,v
retrieving revision 1.24
diff -c -u -p -r1.24 wall.c
--- wall.c	7 Aug 2003 11:17:14 -0000	1.24
+++ wall.c	5 Jul 2004 17:30:13 -0000
@@ -88,11 +88,12 @@ main(int argc, char **argv)
 	int ch;
 	struct iovec iov;
-	char *p, **mem;
+	char *p, **mem, linedev[PATH_MAX];
 	struct utmpentry *ep;
 	gid_t egid;
 	struct wallgroup *wg;
 	struct passwd *pw;
+	struct stat sb;
 	time_t atime;
@@ -146,6 +147,10 @@ main(int argc, char **argv)
 			if (ingroup == 0)
+		snprintf(linedev, PATH_MAX, _PATH_DEV "%s", ep->line);
+		linedev[PATH_MAX-1] = '\0';
+		if (stat(linedev, &sb))
+			continue;
 		if ((p = ttymsg(&iov, 1, ep->line, 60*5)) != NULL)
 			warnx("%s", p);