From owner-freebsd-bugs@FreeBSD.ORG Tue Jan 6 20:01:16 2009 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0CCE41065675; Tue, 6 Jan 2009 20:01:16 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe03.swip.net [212.247.154.65]) by mx1.freebsd.org (Postfix) with ESMTP id 35B7C8FC21; Tue, 6 Jan 2009 20:01:14 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=6nre6YQGT9EA:10 a=4zEhLDbpA8gA:10 a=rREUrScshOl7G2h6aTFPgw==:17 a=6I5d2MoRAAAA:8 a=r1VmykRYRP7822xumlIA:9 a=a57oFEe53sOnipf-YysA:7 a=7kkEK9jHXEuFdNR4vvE87SCbptgA:4 a=9aOQ2cSd83gA:10 a=MSl-tDqOz04A:10 a=SV7veod9ZcQA:10 a=LY0hPdMaydYA:10 Received: from [62.73.248.227] (account mc467741@c2i.net [62.73.248.227] verified) by mailfe03.swip.net (CommuniGate Pro SMTP 5.2.6) with ESMTPA id 1180331026; Tue, 06 Jan 2009 21:01:10 +0100 From: Hans Petter Selasky To: "M. Warner Losh" Date: Tue, 6 Jan 2009 21:03:27 +0100 User-Agent: KMail/1.9.7 References: <7d6fde3d0901061110r79333a07jf4eb134224a94747@mail.gmail.com> <200901062024.31100.hselasky@c2i.net> <20090106.125218.1159136480.imp@bsdimp.com> In-Reply-To: <20090106.125218.1159136480.imp@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200901062103.28124.hselasky@c2i.net> Cc: volker@vwsoft.com, yanefbsd@gmail.com, freebsd-bugs@freebsd.org, freebsd-usb@freebsd.org Subject: Re: bin/129963: [newusb] usbconfig(8) fails with misleading error when run as a normal user X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Jan 2009 20:01:16 -0000 On Tuesday 06 January 2009, M. Warner Losh wrote: > In message: <200901062024.31100.hselasky@c2i.net> > > Hans Petter Selasky writes: > : On Tuesday 06 January 2009, M. Warner Losh wrote: > : > In message: > : > <7d6fde3d0901061110r79333a07jf4eb134224a94747@mail.gmail.com> > : > > : > "Garrett Cooper" writes: > : > : On Tue, Jan 6, 2009 at 10:32 AM, Hans Petter Selasky > : > : > : > : wrote: > : > : > On Saturday 03 January 2009, Volker wrote: > : > : >> On 01/03/09 01:35, Hans Petter Selasky wrote: > : > : >> > On Wednesday 31 December 2008, vwe@freebsd.org wrote: > : > : >> >> Synopsis: [newusb] usbconfig(8) fails with misleading error > : > : >> >> when run as a normal user > : > : >> >> > : > : >> >> Responsible-Changed-From-To: freebsd-bugs->freebsd-usb > : > : >> >> Responsible-Changed-By: vwe > : > : >> >> Responsible-Changed-When: Wed Dec 31 12:55:52 UTC 2008 > : > : >> >> Responsible-Changed-Why: > : > : >> >> reassign > : > : >> >> > : > : >> >> http://www.freebsd.org/cgi/query-pr.cgi?pr=129963 > : > : >> > > : > : >> > Hi, > : > : >> > > : > : >> > "usbconfig" will only show USB devices which the user has access > : > : >> > to. > : > : >> > > : > : >> > What should be the correct display message when no devices are > : > : >> > accessible due to innsufficient permissions? > : > : >> > > : > : >> > --HPS > : > : >> > : > : >> Hans, > : > : >> > : > : >> what about "access denied" or "insufficient privileges"? > : > : >> > : > : >> Someone might have a better idea but everything should be better > : > : >> than silently refusing to do anything. > : > : >> > : > : >> Volker > : > : > > : > : > Is this Ok: > : > : > > : > : > http://perforce.freebsd.org/chv.cgi?CH=155731 > : > : > > : > : > --HPS > : > : > : > : Eh? I still think that strerror or something along those lines would > : > : be more helpful. > : > : > : > : You could also do > : > : > : > : if (getuid() != 0) { > : > : errx(1, "Cluebat -- you might not be able to read the usb devices > : > : if you're not root"); > : > : } > : > : > : > : or... > : > : > : > : struct stat usb_s; > : > : > : > : int fd = open(..., O_RDONLY /* blah, blah... */); > : > : > : > : if (fd == -1) { > : > : errx(1, "Does the file -- %s -- exist?", file); > : > : } > : > : > : > : if (fstat(fd, &usb_s) == -1) { > : > : errx(1, "Couldn't stat the file: %s", file); > : > : } > : > : > : > : if (!S_IRUSR(usb_s.st_mode) && !S_IRGRP(usb_s.st_mode) && > : > : !S_IROTH(usb_s.st_mode)) { > : > : errx(1, "File not readable (do you have read permissions?)"); > : > : } > : > : > : > : /* Continue on merry way reading devices; maybe use strerror(3) for > : > : more intuitive error messages? */ > : > : > : > : Thoughts? > : > > : > Do you really have to be root to find the devices, if so, that's bad. > : > Very bad. xsane refuses to run as root. I have: > : > : No, no. That's wrong. > : > : Do it like this for example: > : > : usbconfig -u xxx -a xxx set_owner xxx set_perm 660 > : > : This won't have no effect at all with USB2: > : > [localrules=10] > : > add path 'uscanner*' mode 0660 > : > > : > to make it work. /dev/usb* in old usb allow listing w/o privs... > > That's bad. I'm sorry, but having to do something weird to get the > scanner to work every time isn't good design. I don't understand. If you are lazy you do: usbconfig -u xxx set_perm 777 That will give everyone access to all USB devices on the given controller "-u xxx". Note: No "-a" argument. Or: usbconfig set_owner warner:wheel set_perm 660 All USB devices ever plugged on your machine will be accessible by you. I think Rink Springer is working on something in this area. --HPS