I just can't do a simple thing as read a string descriptor. Here's the simple code with pyusb wrapper(just for simplicity of code) but the problem remains even with le libsub original library.
import usb.core
import usb.util
devs = usb.core.find(find_all=True)
for dev in devs:
try:
print usb.util.get_string(dev, 255, dev.iManufacturer)
except usb.core.USBError:
pass
If I execute this without root permissions i get nothing(all loop iteration raise an exception). If I execute with root permissions I get some string descriptor and some exception. In this case I know the exception is normal because the pipe error means the device does not provide any string descriptor.
The question is: how can I get the string descriptors without the root permissions? The command lsusb
retrieves all the informations and it does it without the suid bit enabled.
I encountered that problem as well. It seems that pyusb by default opens devices read-write, while
lsusb
opens them read-only, as can be seen in this$ strace lsusb
extract:I solved the problem by making all usb devices world-read/writable, but that's definitely not optimal from a security standpoint (keyloggers, etc)...