From owner-freebsd-questions@FreeBSD.ORG Thu Nov 1 19:55:10 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AA96716A550 for ; Thu, 1 Nov 2007 19:55:10 +0000 (UTC) (envelope-from jhary@unsane.co.uk) Received: from unsane.co.uk (unsane-pt.tunnel.tserv2.fmt.ipv6.he.net [IPv6:2001:470:1f03:1f1::2]) by mx1.freebsd.org (Postfix) with ESMTP id 17E0C13C4A7 for ; Thu, 1 Nov 2007 19:55:09 +0000 (UTC) (envelope-from jhary@unsane.co.uk) Received: from crab.unsane.co.uk (crab.unsane.co.uk [10.0.0.111]) (authenticated bits=0) by unsane.co.uk (8.14.0/8.14.0) with ESMTP id lA1Jt3tp031393 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 1 Nov 2007 19:55:03 GMT (envelope-from jhary@unsane.co.uk) Message-ID: <472A2EDD.1050706@unsane.co.uk> Date: Thu, 01 Nov 2007 19:54:05 +0000 From: Vince User-Agent: Thunderbird 2.0.0.6 (X11/20071101) MIME-Version: 1.0 To: Darren Spruell References: <839aec700711011053i3b4d7c7dmbbd5afde03ba513a@mail.gmail.com> In-Reply-To: <839aec700711011053i3b4d7c7dmbbd5afde03ba513a@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: Set perms on attach of USB umass disk X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Nov 2007 19:55:10 -0000 Darren Spruell wrote: > I've been trying (and failing) to figure out how to adjust ownership > or permissions of a USB memory stick on device attach. > > > umass0: SanDisk Corporation Cruzer Mini, rev 2.00/0.20, addr 5 > da0 at umass-sim0 bus 0 target 0 lun 0 > da0: Removable Direct Access SCSI-2 device > da0: 1.000MB/s transfers > da0: 977MB (2001888 512 byte sectors: 64H 32S/T 977C) > > $ usbdevs -v > Controller /dev/usb0: > addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), > Intel(0x0000), rev 1.00 > port 1 addr 2: full speed, power 100 mA, config 1, Dell USB Keyboard > Hub(0x1004), Dell(0x413c), rev 48.01 > port 1 addr 3: low speed, power 90 mA, config 1, Dell USB Keyboard > Hub(0x2006), Dell(0x413c), rev 48.00 > port 2 addr 5: full speed, power 100 mA, config 1, Cruzer > Mini(0x5150), SanDisk Corporation(0x0781), rev 0.20 > > > I've tried altering devfs.conf but this appears to only work for > devices that are attached at startup of devfs. I've tried configuring > devd(8): > > attach 100 { > device-name "da[0-9]+s1"; > action "/bin/chmod 0660 $device-name"; > }; > > attach 100 { > device-name "da[0-9]+"; > action "/bin/chmod 0660 $device-name"; > }; > > Neither of these seem to result in the permission change I'm after > (making device writable by my user which is in the operator group): > > $ ls -l /dev/da0* > crw-r----- 1 root operator 0, 165 Oct 21 13:08 /dev/da0 > crw-r----- 1 root operator 0, 166 Oct 21 13:08 /dev/da0s1 > > What's the right way to handle this? > create a new file /etc/devfs.rules with contents [system=10] add path 'da*' mode 660 group operator Then in /etc/rc.conf add devfs_system_ruleset="system" and restart devfs (/etc/rc.d/devfs restart) This should do the job, for futher reading devfs.rules has a manpage. Vince