Linux non-root device permissions?

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

Linux non-root device permissions?

Postby NVRAM » Thu Aug 23, 2007 3:28 am

I'm running Fedora Core 5, and using Lejos 0.3.0-alpha for my NXT.

I'm trying to figure out how others have addressed the issue that the transient device files /dev/bus/usb/*/* are only writable by root. I've managed to kludge it, but it's unsightly.

In one topic (http://lejos.sourceforge.net/forum/viewtopic.php?t=75#317),
lawrie

PostPosted: Tue May 01, 2007 12:35 pm
The most likely reason to get this problem on Linux is not having permissions to the usb device from a non-root user. See Readme.html for ways of setting the permissions.

And the README.html contains:
A better solution is to use udev rules or pamcomsole. How to do this varies with different Linux systems. A pamconsole solution that works on Fedora Core 5, is to create a file /etc/security/console.perms.d/60-libusb.perms with the two lines:

<usbdevices>=/dev/bus/usb/*/*
<console> 0600 <usbdevices> 0644 root

My fix was an "add" UDEV rule that uses the device name /dev/usbdevXX.YY_* and then sets the permissions and ownership on /dev/bus/usb/0XX/0YY. It works, but isn't especially elegant.

Does anyone else have a better solution?
NVRAM
New User
 
Posts: 17
Joined: Tue Aug 21, 2007 5:25 am

Postby CoBB » Thu Aug 23, 2007 6:51 am

The problem with setting rights on the device files themselves is that the numbers keep changing as you unplug and plug them in again. I’m on Debian, but the same udev rules should work for you too. I created a file called /etc/udev/rules.d/70-lego.rules and populated it with the following lines:

Code: Select all
# Lego NXT
BUS=="usb", SYSFS{idVendor}=="03eb", GROUP="lego", MODE="0660"
BUS=="usb", SYSFS{idVendor}=="0694", GROUP="lego", MODE="0660"

After restarting udev I added the necessary users to the lego group and voilà! If it doesn’t work, you should check the vendor id with lsusb after connecting the brick. I only encountered the two above (0694 is Lego Group, while 03eb is Atmel Corp) so far.
User avatar
CoBB
Novice
 
Posts: 73
Joined: Tue Apr 24, 2007 12:24 pm

Postby NVRAM » Thu Aug 23, 2007 3:09 pm

CoBB wrote:
Code: Select all
# Lego NXT
BUS=="usb", SYSFS{idVendor}=="03eb", GROUP="lego", MODE="0660"
BUS=="usb", SYSFS{idVendor}=="0694", GROUP="lego", MODE="0660"

<snip> If it doesn’t work, you should check the vendor id with lsusb after connecting the brick. I only encountered the two above (0694 is Lego Group, while 03eb is Atmel Corp) so far.


Ahhhh. Cool, that works perfectly. I tried something similar, but my rule file only had '0694', since that's all that udevinfo showed. And that only affected the /dev/usbdevXX.YY_* file, which doesn't help.

So I had added a "RUN" script that used $DEVICENAME to determine the bus and device addresses, then plugged them in as XX and YY to set the permissions:
My fix was an "add" UDEV rule that uses the device name /dev/usbdevXX.YY_* and then sets the permissions and ownership on /dev/bus/usb/0XX/0YY. It works, but isn't especially elegant.

BTW, I don't have lsusb what package is it in? I only have udevinfo and it's about as user-friendly as a pit bull on PCP.

Does anyone want to add your solution to the README.html? It works on FC5, Debian and I'll try to test it on Suse 10 today.

Thanks again!
NVRAM.
NVRAM
New User
 
Posts: 17
Joined: Tue Aug 21, 2007 5:25 am

Postby CoBB » Thu Aug 23, 2007 3:25 pm

NVRAM wrote:BTW, I don't have lsusb what package is it in? I only have udevinfo and it's about as user-friendly as a pit bull on PCP.

It is in usbutils.

NVRAM wrote:Does anyone want to add your solution to the README.html? It works on FC5, Debian and I'll try to test it on Suse 10 today.

I found it somewhere on the web too, only the vendor id was different from mine (I have two bricks, and they differ in this respect, but not in any other perceivable way).
User avatar
CoBB
Novice
 
Posts: 73
Joined: Tue Apr 24, 2007 12:24 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff