[snap] Chromium cannot use WebUSB

Bug #1780678 reported by Romain G on 2018-07-08
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
chromium-browser (Ubuntu)
Medium
Olivier Tilloy

Bug Description

We're running into a weird bug on Ubuntu : WebUSB works on Chrome but doesn't on Chromium!

Here's our udev rule:

https://workshop.numworks.com/files/drivers/linux/50-numworks-calculator.rules

It uses the uaccess tag which adds an ACL to the created file in /dev/ so that the current logged-in user has RW access to the corresponding /dev/bus/usb/** device. Apparently that's the way to go, since relying on groups is fragile (not all distros use the "plugdev" group for example).

That udev rules works just fine. When using a command-line utility such as "dfu-tool", the USB device is seen and can be read from and written to. It also works just fine on Chrome. But Chromium gives us an "access denied" error. It lists the device, we do get the pop-up, but we cannot communicate. On Chromium, chrome://device-log says :

Failed to open /dev/bus/usb/001/011: Operation not permitted (1)

Here are the infos on said file:

user@virtualbox:~$ ls -l /dev/bus/usb/001/011
crw-rw-r--+ 1 root root 189, 10 Jul 3 11:35 /dev/bus/usb/001/011

As you can see, the file is owned root/root, but has an ACL (as shown by the "+" symbol)

user@virtualbox:~$ getfacl /dev/bus/usb/001/011
getfacl: Removing leading '/' from absolute path names
# file: dev/bus/usb/001/011
# owner: root
# group: root
user::rw-
user:user:rw-
group::rw-
mask::rw-
other::r--

Here the ACL supposedely gives RW access to "user" who is indeed the current logged-in user, and the user running Chromium and Chrome.

For reference :
 - Latest stable Ubuntu (18.04)
 - Using the Chromium that ships with Ubuntu (from the Ubuntu Software app. attached chrome://version page)
 - And using latest stable Chrome from google.com (attached chrome://version page)

Romain G (ecco2) wrote :
Romain G (ecco2) wrote :
Romain G (ecco2) on 2018-07-11
affects: chromium (Ubuntu) → chromium-browser (Ubuntu)
summary: - Chromium cannot use WebUSB
+ Chromium cannot use WebUSB (works fine in Chrome)

You're using the snap version of chromium, which is strictly confined, and thus won't let you access /dev/bus/usb/001/011 by design.

Using chromium-browser from the ubuntu archive should allow you to see your device:

    sudo apt install chromium-browser
    chromium-browser

Now, I'm also interested in your feedback on testing a version of the snap that allows access to USB devices:

    sudo snap refresh chromium --channel=candidate/raw-usb-test
    sudo snap connect chromium:raw-usb
    snap run chromium

Please let me know if that version lets you see your device.

Note that both the snap package and the deb package can coexist on your system without a problem. You can tell which package you're running by checking the command line in chrome://version.

Thanks in advance for your feedback!

tags: added: snap
summary: - Chromium cannot use WebUSB (works fine in Chrome)
+ [snap] Chromium cannot use WebUSB
Erik van Konijnenburg (ekonijn) wrote :

Tested with the Numworks calculator v0100, Ubuntu 19.10.

$ dpkg -l chromium-browser
...
ii chromium-browser 77.0.3865.120-0ubuntu1.19.10.1 amd64 Transitional package - chromium-browser -> chromium snap
$ snap changes
ID Status Spawn Ready Summary
36 Done today at 10:20 CET today at 10:20 CET Refresh "chromium" snap from "candidate/raw-usb-test" channel
$ snap interface raw-usb
name: raw-usb
summary: allows raw access to all USB devices
slots:
  - core
$ sudo snap connect chromium:raw-usb
error: snap "chromium" has no plug named "raw-usb"

And without this connect, chrome://device-log/ says 'operation not permitted',
as designed.

At this point, the workaround of using chromium without a snap wrapper seems no longer available. The snap system knows something about raw-usb, but the chromium snap from the raw-usb-test channel does not want to connect to it.

Let me know when you want further testing.

Olivier Tilloy (osomon) wrote :

@Erik: I just published an updated version of the chromium snap with the additional raw-usb plug in the candidate/raw-usb channel.

Can you please test and report whether this gives you access to your USB device?

    snap refresh chromium --channel=candidate/raw-usb
    snap connect chromium:raw-usb

If it doesn't, can you please share the output of "journalctl -f | grep DEN" running in another terminal window while observing the problem?

Erik van Konijnenburg (ekonijn) wrote :

Yes, that did the trick. No error messages while connecting, web-site could detect and update the device over USB without problems.

Thanks for your help!

Olivier Tilloy (osomon) wrote :

Excellent, thanks for testing and for the feedback Erik. I am going to add the raw-usb plug to the snap in all channels then.

Changed in chromium-browser (Ubuntu):
assignee: nobody → Olivier Tilloy (osomon)
importance: Undecided → Medium
status: New → In Progress
Olivier Tilloy (osomon) wrote :
Changed in chromium-browser (Ubuntu):
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers