This forum has been archived. All content is frozen. Please use KDE Discuss instead.

USB group/priv

Tags: None
(comma "," separated)
Anonymous Koala
Karma
0

USB group/priv

Mon May 07, 2018 11:30 pm
This should be simple. Perhaps I'm just being brain dead, but I cannot identify the group/priv which gives an account the ability to directly access USB devices. This is not a desktop issue, it is a programming issue. I'm experimenting with Qt and libusb. The first post of the series is http://www.logikalsolutions.com/wordpress/information-technology/qt-and-usb-pt-1/ if that matters to you.

Somebody really cheated with sudo too.

roland@roland-I5-HP-Compaq-8300-Elite-SFF-PC:~/Projects/build-myusb-Desktop-Debug$ groups
roland adm dialout cdrom sudo dip plugdev lpadmin sambashare
roland@roland-I5-HP-Compaq-8300-Elite-SFF-PC:~/Projects/build-myusb-Desktop-Debug$ sudo groups
[sudo] password for roland:
root

There should be a group which, just like dialout, gives a user access to the hardware. For those who don't know, dialout allows you to directly access a serial port. I thought plugdev "should" do it, but, obviously not.

out << "Number of possible configurations: " << (int)desc.bNumConfigurations << " ";
out << "Device Class: " << (int)desc.bDeviceClass<<" ";
out << "VendorID: " << desc.idVendor << " ";
out << "ProductID: " << desc.idProduct << endl;

r0_status = libusb_open(dev, &hHandle);
if (r0_status != LIBUSB_SUCCESS)
{
out << "Error " << r0_status << " opening USB device. Error text: " << libusb_error_name(r0_status) << endl;
}
else
{
unsigned char serialNumber[255] = { };
unsigned char vendorName[1024] = { };
unsigned char productName[1024] = { };

int textSize = libusb_get_string_descriptor_ascii(hHandle, desc.iSerialNumber, serialNumber, sizeof(serialNumber));
textSize = libusb_get_string_descriptor_ascii(hHandle, desc.idVendor, vendorName, sizeof(vendorName));
textSize = libusb_get_string_descriptor_ascii(hHandle, desc.idProduct, productName, sizeof(productName));

out << "Vendor: " << (char *)vendorName << " Product: " << (char *)productName << " Serial Number: " << (char *)serialNumber << endl;
}


Running as my mere mortal self I basically see the following:

Code: Select all
        out << "Number of possible configurations: " << (int)desc.bNumConfigurations << "   ";
        out << "Device Class: " << (int)desc.bDeviceClass<<"  ";
        out << "VendorID: " << desc.idVendor << "   ";
        out << "ProductID: " << desc.idProduct << endl;

        r0_status = libusb_open(dev, &hHandle);
        if (r0_status != LIBUSB_SUCCESS)
        {
            out << "Error " << r0_status << " opening USB device. Error text: " << libusb_error_name(r0_status) << endl;
        }
        else
        {
            unsigned char serialNumber[255] = { };
            unsigned char vendorName[1024] = { };
            unsigned char productName[1024] = { };

            int textSize = libusb_get_string_descriptor_ascii(hHandle, desc.iSerialNumber, serialNumber, sizeof(serialNumber));
            textSize = libusb_get_string_descriptor_ascii(hHandle, desc.idVendor, vendorName, sizeof(vendorName));
            textSize = libusb_get_string_descriptor_ascii(hHandle, desc.idProduct, productName, sizeof(productName));

            out << "Vendor: " << (char *)vendorName << "  Product: " << (char *)productName << "  Serial Number: " << (char *)serialNumber << endl;
        }


The QtCreator application output window shows lots of this:
Code: Select all
Debugging starts
libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/002/002: Permission denied
libusb: error [_get_usbfs_fd] libusb requires write access to USB device nodes.
libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/002/001: Permission denied
libusb: error [_get_usbfs_fd] libusb requires write access to USB device nodes.
libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/001/003: Permission denied


sudo this same executable from the command line produces:

Debugging starts
libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/002/002: Permission denied
libusb: error [_get_usbfs_fd] libusb requires write access to USB device nodes.
libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/002/001: Permission denied
libusb: error [_get_usbfs_fd] libusb requires write access to USB device nodes.
libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/001/003: Permission denied


Yes, I've read the on-line places about creating UDEV rules, but, that should not be required. Something in the following list (other than root) should allow direct USB access without a new udev rule. We went down this path with serial and parallel ports. Did we learn nothing?

Code: Select all
roland@roland-I5-HP-Compaq-8300-Elite-SFF-PC:~/Projects/build-myusb-Desktop-Debug$ cut -d: -f1 /etc/group | sort
adm
audio
avahi
avahi-autoipd
backup
bin
bluetooth
boinc
cdrom
colord
crontab
daemon
dialout
dip
disk
fax
floppy
games
geoclue
gnats
input
irc
kmem
list
lp
lpadmin
mail
man
messagebus
mlocate
netdev
news
nogroup
operator
plugdev
postdrop
postfix
postgres
proxy
pulse
pulse-access
roland
root
rtkit
sambashare
saned
sasl
scanner
sddm
shadow
src
ssh
ssl-cert
staff
sudo
sys
syslog
systemd-bus-proxy
systemd-journal
systemd-network
systemd-resolve
systemd-timesync
tape
tty
users
utmp
uucp
uuidd
vboxusers
video
voice
www-data


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]