From owner-freebsd-questions@FreeBSD.ORG Thu Sep 18 13:21:21 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A573416A4BF for ; Thu, 18 Sep 2003 13:21:21 -0700 (PDT) Received: from priv-edtnes61.telusplanet.net (outbound01.telus.net [199.185.220.220]) by mx1.FreeBSD.org (Postfix) with ESMTP id 33DA443FB1 for ; Thu, 18 Sep 2003 13:21:20 -0700 (PDT) (envelope-from cpressey@catseye.mine.nu) Received: from kallisti.ca ([207.81.23.108]) by priv-edtnes61.telusplanet.netSMTP <20030918202119.BXVR25839.priv-edtnes61.telusplanet.net@kallisti.ca>; Thu, 18 Sep 2003 14:21:19 -0600 Date: Thu, 18 Sep 2003 13:23:52 -0700 From: Chris Pressey To: freebsd-questions@freebsd.org Message-Id: <20030918132352.4f1ac8b7.cpressey@catseye.mine.nu> In-Reply-To: <20030918120453.2d558777.cpressey@catseye.mine.nu> References: <20030918110025.5b15edfa.cpressey@catseye.mine.nu> <20030918120453.2d558777.cpressey@catseye.mine.nu> Organization: Cat's Eye Technologies X-Mailer: Sylpheed version 0.9.4 (GTK+ 1.2.10; i386-portbld-freebsd4.8) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit cc: danfe@regency.nsu.ru Subject: Re: svgalib program is setuid root but still can't seem to allocate graphics console X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Sep 2003 20:21:21 -0000 On Thu, 18 Sep 2003 12:04:53 -0700 Chris Pressey wrote: > On Thu, 18 Sep 2003 11:00:25 -0700 > Chris Pressey wrote: > > > Hi, > > > > I'm trying to write some code that uses /usr/ports/graphics/svgalib. > > > > I've started off with the first example program on: > > > > http://www.svgalib.org/jay/beginners_guide/beginners_guide.html > > > > As root, I can compile and run it fine, and I get the message: > > > > [svgalib: allocated virtual console #10] > > > > And if I try to run it as a normal user, I get: > > > > svgalib: Cannot get I/O permissions. > > > > This is expected, because the program is not setuid root. So as > > root I chmod u+s it, but then when I run it as a normal user I get: > > > > You must be the owner of the current console to use svgalib. > > Not running in a graphics capable console, > > and unable to find one. > > Using RAGE driver, 8192KB. ChipID:35 MemType:6 > > Rage: BIOS reports base frequency=28.636MHz Denominator= 31 > > svgalib 1.4.3 > > You must be the owner of the current console to use svgalib. > > Not running in a graphics capable console, > > and unable to find one. > > Not running in a graphics capable console, > > and unable to find one. > > > > This is on ttyv0, btw. I'm running X on ttyv9. > > Followup: this is happening not just with my own program, but with > programs in the ports tree like /usr/ports/graphics/acidwarp and > /usr/ports/graphics/seejpeg, on both of my FreeBSD machines: > > FreeBSD foo 4.9-PRERELEASE FreeBSD 4.9-PRERELEASE #0: Thu Aug 28 > 11:26:32 CDT 2003 root@foo:/usr/obj/usr/src/sys/FOO i386 > > FreeBSD bar 4.9-PRERELEASE FreeBSD 4.9-PRERELEASE #3: Tue Sep 9 > 11:35:09 CDT 2003 root@bar:/usr/obj/usr/src/sys/BAR i386 > > Both machines contain this in their dmesg: > > vga0: at port 0x3c0-0x3df iomem 0xa0000-0xbffff on > isa0 > > But in short this doesn't feel like a video problem, it feels like a > setuid-bit/svgalib/both problem. > > Is anyone else experiencing these sorts of problems? Was there some > recent STABLE change regarding setuid/svgalib that I missed? > > -Chris Oho, I found something! If I (as a normal user) happen to be logged in on ttyv1 as well as ttyv0, I *can* run seejpeg from ttyv0. Likewise, if I'm logged in on ttyv2, I can run it on ttyv1... It looks like there's an off-by-one error in vga.c: The function check_owner() takes an argument which is the number of the current virtual console. This number is retrieved by a call to ioctl(..., VT_GETACTIVE, &vts) Has perhaps this ioctl changed lately, where it's returning 1 instead of 0, for ttyv0? It would be simple enough to prepare a patch and a PR for this, but it would be nice to know if this is affecting other people, and why its happening, first. -Chris