You are not logged in.

#1 2009-01-22 09:29:55

chsims1
Member
From: Holderness, UK
Registered: 2008-11-25
Posts: 83

[Solved] Problem with program access to USB device as normal user.

Hi,

I have a python program which accesses a USB device.  This works fine when run as 'su' but not as a normal user.  I can access USB sticks etc. ok as a normal user.

As a noob, this sounds to me like something connected with Udev rules, but I really have no idea exactly what I need to do to provide the access to the python program as a normal user.  Help please smile

Last edited by chsims1 (2009-01-22 11:31:08)

Offline

#2 2009-01-22 10:40:34

biagio
Member
From: Florence - Italy
Registered: 2008-02-29
Posts: 49

Re: [Solved] Problem with program access to USB device as normal user.

try to put your username instead of 0 in the line <policy user="0"> in the file /etc/dbus-1/system.d/hal.conf
and restart hal with:
sudo /etc/rc.d/hal restart

Last edited by biagio (2009-01-22 11:09:24)

Offline

#3 2009-01-22 11:30:44

chsims1
Member
From: Holderness, UK
Registered: 2008-11-25
Posts: 83

Re: [Solved] Problem with program access to USB device as normal user.

Ok Solved after some reading .....

1. Find where the device is mounted by running dmesg | tail before and after connecting it.
2. Find the vendor and product numbers by using udevadm on the above mount point.
3. Create a new udev rule in /etc/udev/rules.d named 85.usb.rules (use whatever you want as long as it ends in .rules):

SYSFS{idVendor}=="1941", SYSFS{idProduct}=="8021", MODE="0660",GROUP="usb"

4. Create a new group 'usb'
5. Add your normal user to that group.

I realise that the number at the beginning of the udev rule name determines the priority of the rule, but would someone like to suggest a "good" value?  It works fine as I have used it here, but I don't want to cause problems further down the line.

Offline

#4 2009-01-22 12:00:47

Wittfella
Member
From: Australia
Registered: 2008-05-27
Posts: 462

Re: [Solved] Problem with program access to USB device as normal user.

Glad that you found a solution, but I was going to ask if you had added your username to the 'storage' and/or 'disk' groups?

Offline

#5 2009-01-22 13:56:18

chsims1
Member
From: Holderness, UK
Registered: 2008-11-25
Posts: 83

Re: [Solved] Problem with program access to USB device as normal user.

Yes, I am a member of the storage group ... presumably otherwise I wouldn't have been able to write/read USB sticks.  I think the problem was that libusb can only be used by root.  Adding the rule allows group (usb) access too.

Offline

Board footer

Powered by FluxBB