From owner-freebsd-stable@FreeBSD.ORG Mon Oct 13 05:23:56 2008 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BA0931065686 for ; Mon, 13 Oct 2008 05:23:56 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from QMTA01.westchester.pa.mail.comcast.net (qmta01.westchester.pa.mail.comcast.net [76.96.62.16]) by mx1.freebsd.org (Postfix) with ESMTP id 62A6E8FC1E for ; Mon, 13 Oct 2008 05:23:55 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from OMTA14.westchester.pa.mail.comcast.net ([76.96.62.60]) by QMTA01.westchester.pa.mail.comcast.net with comcast id S4891a01W1HzFnQ515Pu7W; Mon, 13 Oct 2008 05:23:54 +0000 Received: from koitsu.dyndns.org ([69.181.141.110]) by OMTA14.westchester.pa.mail.comcast.net with comcast id S5Pt1a0042P6wsM3a5PtfM; Mon, 13 Oct 2008 05:23:54 +0000 X-Authority-Analysis: v=1.0 c=1 a=4mEp2veIISoA:10 a=lhY6n5EmVM4A:10 a=QycZ5dHgAAAA:8 a=qG2iY9QqcwcX3ZYElD8A:9 a=6zRBgZCkzZx05OVYh6wA:7 a=5ywBp_GvOGs-ZP2IHZ_-28y8lFMA:4 a=EoioJ0NPDVgA:10 a=MSl-tDqOz04A:10 a=vv3bomIY6ZkA:10 a=LY0hPdMaydYA:10 Received: by icarus.home.lan (Postfix, from userid 1000) id 4C023C9419; Sun, 12 Oct 2008 22:23:53 -0700 (PDT) Date: Sun, 12 Oct 2008 22:23:53 -0700 From: Jeremy Chadwick To: "Carlos A. M. dos Santos" Message-ID: <20081013052353.GA10013@icarus.home.lan> References: <20080910203445.GA8561@mr-happy.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Cc: freebsd-stable@freebsd.org, Jeff Blank Subject: Re: can't see non-root writes to /dev/console X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Oct 2008 05:23:56 -0000 On Mon, Oct 13, 2008 at 03:16:37AM -0200, Carlos A. M. dos Santos wrote: > On Wed, Sep 10, 2008 at 11:54 PM, Carlos A. M. dos Santos > wrote: > > On Wed, Sep 10, 2008 at 5:34 PM, Jeff Blank wrote: > >> I just upgraded a RELENG_7 (amd64) box from 20080714 to "latest" > >> (which seems to be from a few days ago--no changes from Monday > >> morning's csup to today's) and can no longer see the effect of writing > >> to /dev/console as non-root. When I log in using xdm, my user owns > >> /dev/console, mode 0622 (-rw--w--w-), and I start an 'xterm -C'. But > >> when I, for example, > >> > >> echo foo > /dev/console > >> > >> I see nothing in the console xterm. No error messages, and echo exits > >> 0. If I su to root and do the same, I get 'foo' in the same console > >> xterm. Syslog messages to /dev/console also appear, of course. All > >> the above applies to xconsole as well, not just xterm. I did > >> recompile xterm from 20080616 ports, but it didn't fix the issue > >> (didn't expect it to, as xterm clearly has no trouble attaching and > >> reading). So my echo is getting lost in the kernel, I guess. > >> > >> Known problem? Intentional change? Something else? > > > > I have seen this problem since 6.x times and still on 7.x. I also > > noticed that if I send something to the console after xconsole starts > > then I can sned messages as an ordinary user. My workaround was > > modifying the Xsetup_0 script (I used xdm for login), adding a line > > with > > > > (sleep 3; date >> "$dev_console") & > > > > just after starting xconsole. > > > > I didn't have time to set up a machine with 8-CURRENT yet, so I could > > not check if the new mp-safe tty implementation fixes this, either > > intentionally or by a fortunate side effect. > > I took some time to look at this again. I'm using 8.0-CURRENT now > (GENERIC kernel), csup'ed and compiled yesterday. Xconsole is unable > to open the console even if my user & group own /dev/console and the > permissions are set to 0622. This happens because of the following > code in xconsole.c: > > 289 int on = 1; > 290 if (ioctl (tty_fd, TIOCCONS, (char *) &on) != -1) > 291 input = fdopen (pty_fd, "r"); > > The ioctl call fails (EPERM) because only superuser can use TIOCCONS, > regardless the ownership of the device. Using xterm with the "-C" > argument works because xterm is installed with the setuid flag bit on. > So the solution is "chmod +us xconsole". Can someone security audit this program before blindly setuid-root'ing it? -- | Jeremy Chadwick jdc at parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP: 4BD6C0CB |