NetBSD Problem Report #26168

Received: (qmail 9386 invoked by uid 605); 5 Jul 2004 17:34:16 -0000
Message-Id: <200407051734.i65HYCkh006630@night-porter.duskware.de>
Date: Mon, 5 Jul 2004 19:34:12 +0200 (CEST)
From: Martin Husemann <martin@duskware.de>
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: martin@duskware.de
To: gnats-bugs@gnats.NetBSD.org
Subject: wall tries to write to non tty lines
X-Send-Pr-Version: 3.95

>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:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 05 17:35:00 +0000 2004
>Closed-Date:    Sun Feb 15 12:43:22 +0000 2009
>Last-Modified:  Sun Feb 15 12:43:22 +0000 2009
>Originator:     Martin Husemann
>Release:        NetBSD 2.0G
>Organization:
>Environment:
System: NetBSD night-porter.duskware.de 2.0G NetBSD 2.0G (PORTER) #5: Sun Jul 4 18:09:04 CEST 2004 martin@night-porter.duskware.de:/usr/src/sys/arch/i386/compile/PORTER i386
Architecture: i386
Machine: i386
>Description:

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.

>How-To-Repeat:

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

>Fix:
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;

 	setprogname(argv[0]);
@@ -146,6 +147,10 @@ main(int argc, char **argv)
 			if (ingroup == 0)
 				continue;
 		}
+		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);
 	}

>Release-Note:
>Audit-Trail:
From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/26168 CVS commit: src/usr.bin/wall
Date: Sun, 15 Feb 2009 06:06:55 +0000 (UTC)

 Module Name:	src
 Committed By:	dholland
 Date:		Sun Feb 15 06:06:55 UTC 2009

 Modified Files:
 	src/usr.bin/wall: wall.c

 Log Message:
 Skip over the ":0" entries that gdm, kdm, and unpatched versions of xdm
 (ours is patched to not do this) leave in utmp. PR 26168.

 I'm doing this by testing for ^:[0-9] in the line field of utmp(x),
 rather than by attempting to stat the device name corresponding to the
 entry as in Martin's patch, because (1) no valid tty should ever have
 a name beginning with a colon, and (2) this way we don't silently skip
 over real ttys that should be there but for some reason have disappeared.

 (I suppose this might conceivably fail to catch entries for displays
 connected via XDCMP; however, ~nobody does that any more and XDCMP is
 a security hole anyhow. If anyone's really concerned about this, let
 me know.)

 In the long run we should look into ways of getting "tty" messages to
 users logged in with an X session and no terminal windows open, as
 that's probably fairly common for the desktop.


 To generate a diff of this commit:
 cvs rdiff -r1.26 -r1.27 src/usr.bin/wall/wall.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 15 Feb 2009 06:10:58 +0000
State-Changed-Why:
Fixed... is this good enough?


State-Changed-From-To: feedback->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Sun, 15 Feb 2009 12:43:22 +0000
State-Changed-Why:
Fine with me


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.