sudo does not work with unbinding usb interface from usbhid driver

Bug #288964 reported by Xiaofan Chen
4
Affects Status Importance Assigned to Milestone
sudo (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

I was looking for a way to dump the HID report descriptor under Linux. For that purpose, I need to detach the kernel usbhid driver from the HID interfaces.

More detail in libusb mailing list archive.
http://www.nabble.com/How-to-dump-HID-report-descriptor-under-Linux-td19609562.html

mcuee@Ubuntu804:~$ uname -a
Linux Ubuntu804 2.6.24-21-generic #1 SMP Mon Aug 25 17:32:09 UTC 2008 i686 GNU/Linux

mcuee@Ubuntu804:/sys/bus/usb/drivers/usbhid$ lsusb
Bus 001 Device 007: ID 04f2:0760 Chicony Electronics Co., Ltd
Bus 001 Device 006: ID ffff:0005
Bus 001 Device 005: ID 046d:c054 Logitech, Inc.
Bus 001 Device 004: ID 14c0:0008
Bus 001 Device 003: ID 1947:0033
Bus 001 Device 002: ID 058f:9360 Alcor Micro Corp. 8-in-1 Media Card Reader
Bus 001 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000

mcuee@Ubuntu804:/sys/bus/usb/drivers/usbhid$ ls
1-3:1.0 1-5:1.0 1-7:1.0 1-7:1.1 bind module new_id uevent unbind

So far so good. But then there is error thereafter. Maybe this is a Ubuntu
specific problem.

mcuee@Ubuntu804:/sys/bus/usb/drivers/usbhid$ sudo echo -n 1-7:1.0 >unbind
bash: unbind: Permission denied
mcuee@Ubuntu804:/sys/bus/usb/drivers/usbhid$ sudo echo -n 1-7:1.1 >unbind
bash: unbind: Permission denied

It turns out that I need to enable root to be able to do the job.
mcuee@Ubuntu804:/sys/bus/usb/drivers/usbhid$ sudo passwd root
[sudo] password for mcuee:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
mcuee@Ubuntu804:/sys/bus/usb/drivers/usbhid$ ls
1-3:1.0 1-5:1.0 1-7:1.0 1-7:1.1 bind module new_id uevent unbind

mcuee@Ubuntu804:/sys/bus/usb/drivers/usbhid$ su -
Password:
root@Ubuntu804:~# cd /sys/bus/usb/drivers/usbhid/
root@Ubuntu804:/sys/bus/usb/drivers/usbhid# ls
1-3:1.0 1-5:1.0 1-7:1.0 1-7:1.1 bind module new_id uevent unbind
root@Ubuntu804:/sys/bus/usb/drivers/usbhid# echo -n 1-7:1.0 >unbind
root@Ubuntu804:/sys/bus/usb/drivers/usbhid# echo -n 1-7:1.1 >unbind

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Thanks, but this is not a bug. To do what you want to do, you need to do the following:

echo -n 1-7:1.0 | tee -a unbind

The reason for this is that the command sequence you are using is actually 2 commands. The first command is "sudo echo -n 1-7:1.0", which is ran as root and echos the character sequence you specified. The second command is "> unbind", which re-directs the output, but this is not running as root.

Changed in sudo:
status: New → Invalid
Revision history for this message
Xiaofan Chen (xiaofanc) wrote :

You are absolutely right and your method works.
Sorry for the false alarming.

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

That's ok :)

Revision history for this message
ALinuxUser (buntulongername-new) wrote :

I am sorry to necrobump, but I don't get it.

$ sudo echo -n '2-3' | tee -a /sys/bus/usb/drivers/usb/unbind

Produces, on my system, this: 'tee: unbind: Permission denied'. Similarly if I have used 'su' to obtain root:

# echo -n '2-3' | tee -a /sys/bus/usb/drivers/usb/unbind
2-3tee: /sys/bus/usb/drivers/usb/unbind: No such device
# ls /sys/bus/usb/drivers/usb
1-1 1-1.2 1-1.6 2-1 bind uevent unbind usb1 usb2 usb3 usb4

Revision history for this message
Seth Arnold (seth-arnold) wrote :

ALinuxUser, Xiaofan Chen's example was unbinding the usbhid driver via the /sys/bus/usb/drivers/usbhid/unbind control file -- yours is using /sys/bus/usb/drivers/usb/unbind instead. You probably have to use the control file that corresponds to the driver your device is using. (Check lsusb -t output.)

Thanks

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.