From owner-freebsd-bugs@FreeBSD.ORG Tue Jan 6 19:17:56 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 AA0281065675; Tue, 6 Jan 2009 19:17:56 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 467F48FC16; Tue, 6 Jan 2009 19:17:56 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id n06JF859038303; Tue, 6 Jan 2009 12:15:08 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Tue, 06 Jan 2009 12:15:21 -0700 (MST) Message-Id: <20090106.121521.2007157328.imp@bsdimp.com> To: yanefbsd@gmail.com From: "M. Warner Losh" In-Reply-To: <7d6fde3d0901061110r79333a07jf4eb134224a94747@mail.gmail.com> References: <495FAFDD.2050206@vwsoft.com> <200901061932.54448.hselasky@c2i.net> <7d6fde3d0901061110r79333a07jf4eb134224a94747@mail.gmail.com> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: volker@vwsoft.com, freebsd-bugs@FreeBSD.org, freebsd-usb@FreeBSD.org, hselasky@c2i.net 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 19:17:58 -0000 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: [localrules=10] add path 'uscanner*' mode 0660 to make it work. /dev/usb* in old usb allow listing w/o privs... Warner