/dev/bus/usb/*/* device file of HP multi-function printer assigned to "audio" group

Bug #1863239 reported by Till Kamppeter
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libmtp (Debian)
Fix Released
Unknown
libmtp (Ubuntu)
Fix Released
Critical
Unassigned

Bug Description

When testing HPLIP I found out that CUPS backends can access my printer only when they are running as root, when they are running as the special user lp, as it is usually the case, they cannot access the printer.

So I tried to find out why and saw that the /dev/bus/usb/*/* device file for the printer has group ownership "audio" and not "lp":

till@till-x1yoga:~/ubuntu/hplip/focal/debian/hplip-3.19.12+dfsg0$ ll /dev/bus/usb/*/*
crw-rw-r-- 1 root root 189, 0 Feb 11 14:17 /dev/bus/usb/001/001
crw-rw-r-- 1 root root 189, 2 Feb 11 14:17 /dev/bus/usb/001/003
crw-rw-r-- 1 root root 189, 3 Feb 11 14:17 /dev/bus/usb/001/004
crw-rw-r-- 1 root plugdev 189, 4 Feb 14 12:23 /dev/bus/usb/001/005
crw-rw-r-- 1 root root 189, 5 Feb 11 14:17 /dev/bus/usb/001/006
crw-rw----+ 1 root audio 189, 62 Feb 14 12:37 /dev/bus/usb/001/063
crw-rw-r-- 1 root root 189, 128 Feb 11 14:17 /dev/bus/usb/002/001
crw-rw-r-- 1 root root 189, 130 Feb 13 09:38 /dev/bus/usb/002/003
till@till-x1yoga:~/ubuntu/hplip/focal/debian/hplip-3.19.12+dfsg0$

The printer is the device /dev/bus/usb/001/063:

till@till-x1yoga:~/ubuntu/hplip/focal/debian/hplip-3.19.12+dfsg0$ lsusb
Bus 002 Device 003: ID 0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 138a:0097 Validity Sensors, Inc.
Bus 001 Device 004: ID 04f2:b5ce Chicony Electronics Co., Ltd Integrated Camera
Bus 001 Device 003: ID 8087:0a2b Intel Corp.
Bus 001 Device 006: ID 056a:50b7 Wacom Co., Ltd Pen and multitouch sensor
Bus 001 Device 063: ID 03f0:7a12 HP, Inc HP OfficeJet Pro 8730
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
till@till-x1yoga:~/ubuntu/hplip/focal/debian/hplip-3.19.12+dfsg0$

There must be a bug somewhere in the UDEV rules.

description: updated
Changed in systemd (Ubuntu):
importance: Undecided → High
Changed in pulseaudio (Ubuntu):
importance: Undecided → High
Changed in systemd (Ubuntu):
milestone: none → ubuntu-20.04
Changed in pulseaudio (Ubuntu):
milestone: none → ubuntu-20.04
Changed in libmtp (Ubuntu):
milestone: none → ubuntu-20.04
importance: Undecided → High
tags: added: focal
Changed in libmtp (Ubuntu):
importance: High → Critical
Changed in pulseaudio (Ubuntu):
importance: High → Critical
Changed in systemd (Ubuntu):
importance: High → Critical
Changed in udev (Ubuntu):
importance: High → Critical
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

An additional remark:

If a Focal system is booted with the printer plugged in and turned on, the group ownership gets correctly set to "lp", but if the printer is only plugged in and/or turned on after boot, it gets "audio" group ownership.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Please provide the udevadm database dump about the device in question a) when it has correct group b) when it does not.

Changed in udev (Ubuntu):
status: New → Invalid
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

udev source package is obsolete and is not used since precise.

Changed in systemd (Ubuntu):
status: New → Incomplete
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

pulseaudio doesn't ship any udev rules that change group permissions of devices. Plus it doesn't run as root, but as an unprivileged user.

Changed in pulseaudio (Ubuntu):
status: New → Invalid
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Attached is the output of

sudo udevadm monitor -e

Output of lsusb:

till@till-x1yoga:~$ lsusb
Bus 002 Device 003: ID 0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 138a:0097 Validity Sensors, Inc.
Bus 001 Device 004: ID 04f2:b5ce Chicony Electronics Co., Ltd Integrated Camera
Bus 001 Device 003: ID 8087:0a2b Intel Corp.
Bus 001 Device 006: ID 056a:50b7 Wacom Co., Ltd Pen and multitouch sensor
Bus 001 Device 012: ID 03f0:7a12 HP, Inc HP OfficeJet Pro 8730
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
till@till-x1yoga:~$

Device is on Bus 001, Device 012, the HP OfficeJet Pro 8730

Here one sees that it is assigned to the "audio" group:

till@till-x1yoga:~$ ls -l /dev/bus/usb/*/*
crw-rw-r-- 1 root root 189, 0 Mar 17 11:45 /dev/bus/usb/001/001
crw-rw-r-- 1 root root 189, 2 Mar 17 11:45 /dev/bus/usb/001/003
crw-rw-r-- 1 root root 189, 3 Mar 17 11:45 /dev/bus/usb/001/004
crw-rw---- 1 root plugdev 189, 4 Mar 18 14:04 /dev/bus/usb/001/005
crw-rw-r-- 1 root root 189, 5 Mar 17 11:45 /dev/bus/usb/001/006
crw-rw----+ 1 root audio 189, 11 Mar 19 18:55 /dev/bus/usb/001/012
crw-rw-r-- 1 root root 189, 128 Mar 17 11:45 /dev/bus/usb/002/001
crw-rw-r-- 1 root root 189, 130 Mar 17 11:45 /dev/bus/usb/002/003
till@till-x1yoga:~$

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Now I tried to investigate from which UDEV rule the wrong setting comes from. First I searched all UDEV rules for the word "audio":

till@till-x1yoga:~$ grep -l '\baudio\b' /*/udev/rules.d/*.rules
/lib/udev/rules.d/50-udev-default.rules
/lib/udev/rules.d/60-persistent-v4l.rules
/lib/udev/rules.d/69-libmtp.rules
/lib/udev/rules.d/70-uaccess.rules
/lib/udev/rules.d/90-pulseaudio.rules
till@till-x1yoga:~$

So I expect only one of these can be the culprit. Actually a 'GROUP="audio"' setting exists only in

/lib/udev/rules.d/50-udev-default.rules

and

/lib/udev/rules.d/69-libmtp.rules

The former is probably no problem as it assigns this group only to devices of 'SUBSYSTEM=="sound"" where the latter seems to be actually the culprit.

First it includes some devices explicitly and then it lists thousands of supported devices. In the end there is some rule for passing a wide range of devices through an auto-probing:

---------
# Autoprobe vendor-specific, communication and PTP devices
ENV{ID_MTP_DEVICE}!="1", ENV{MTP_NO_PROBE}!="1", ENV{COLOR_MEASUREMENT_DEVICE}!="1", ENV{ID_GPHOTO}!="1", ENV{libsane_matched}!="yes", ATTR{bDeviceClass}=="00|02|06|ef|ff", PROGRAM="mtp-probe /sys$env{DEVPATH} $attr{busnum} $attr{devnum}", RESULT=="1", SYMLINK+="libmtp-%k", MODE="660", GROUP="audio", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"
---------

And this auto-probing tests positive on my printer:

till@till-x1yoga:~$ /lib/udev/mtp-probe /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1 001 012
1
till@till-x1yoga:~$

The device path of the printer I have taken from the blob in the udevadm output (attached to previous comment) which also contains "ID_MEDIA_PLAYER=1". So mtp-probe identifies my printer as a media player and assigns the device file to the "audio" group.

I assume that this happens to most or even all HP printers, so an exclusion of only my device via Vendor and Product ID would not be the correct solution.

Either mtp-probe needs to get fixed or before said rule in the end of the 69-libmtp.rules file and after the lines explicitly identifying media players from HP, there should be placed a line to exclude further HP devices, like

----------
...
# Exclude any further, not explicitly specified HP devices
ATTR{idVendor}=="03f0", GOTO="libmtp_rules_end"
# Autoprobe vendor-specific, communication and PTP devices
ENV{ID_MTP_DEVICE}!="1", ENV{MTP_NO_PROBE}!="1", ENV{COLOR_MEASUREMENT_DEVICE}!="1", ENV{ID_GPHOTO}!="1", ENV{libsane_matched}!="yes", ATTR{bDeviceClass}=="00|02|06|ef|ff", PROGRAM="mtp-probe /sys$env{DEVPATH} $attr{busnum} $attr{devnum}", RESULT=="1", SYMLINK+="libmtp-%k", MODE="660", GROUP="audio", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

LABEL="libmtp_rules_end"
----------

Changed in systemd (Ubuntu):
status: Incomplete → Invalid
Changed in libmtp (Ubuntu):
status: New → Confirmed
tags: added: rls-ff-incoming
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

There was already a measure against wrongly identifying HP printers as media players, but it is a rather dirty workaround which does not work any more (therefore this bug). The rule in the end of 69-libmtp.rules checks the absence of the env variable libsane_matched and this variable is set for all HP printers by HPLIP. First, this rule fails miserably if HPLIP is not installed, and I cannot imagine that the libmtp package depends on HPLIP only to identify unsupported devices. Also the libmtp rules are applied for both "add" and "bind" actions, whereas the rules of HPLIP (56-hpmud.rules) are only applied for "add" and so the bug happens on a "bind" action, here the HPLIP rules do not set said env variable and so the libmtp rules probe the HP printers.

One can theoretically work around this problem by mucking with the UDEV rules of HPLIP, but this is a REALLY DIRTY workaround, so please DO NOT add an hplip task to this bug report.

In addition, HPLIP will not be installed by default any more in the not too far future, as prnting and scanning will get snapped. Also we want printer driver Snaps (Printer Applications) not to run as root if possible, so we need to be sure that USB printer device files always belong to the group "lp" for all printer manufacturers and without HPLIP.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

The attached patch would fix this bug. It adds two rules to skip printers. The second skips all kinds of printers by checking whether the standard interface of a printer is present in the USB device. The first skips HP printers, it is the same rule as HPLIP uses. I have added it because it covers a second interface, which is probably of some weird proprietary HP printer devices. For my printer the bug goes away with this patch, also with any one of the two rules commented out.

I think one can assume that there is no printer available which doubles as a media player.

tags: added: patch
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Correction for the patch, please use this one.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Attached debdiff fixes this bug in the libmtp package, applying effectively the patch of the previous comment.

Changed in libmtp (Ubuntu):
status: Confirmed → Fix Committed
status: Fix Committed → In Progress
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :
Mathew Hodson (mhodson)
no longer affects: pulseaudio (Ubuntu)
no longer affects: systemd (Ubuntu)
no longer affects: udev (Ubuntu)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libmtp - 1.1.17-2ubuntu1

---------------
libmtp (1.1.17-2ubuntu1) focal; urgency=medium

  * In 69-libmtp.rules skip all printers, including some weird ones from HP
    as some test positive on mtp-probe (LP: #1863239).

 -- Till Kamppeter <email address hidden> Sat, 21 Mar 2020 19:05:58 +0100

Changed in libmtp (Ubuntu):
status: In Progress → Fix Released
Changed in libmtp (Debian):
status: Unknown → Fix Released
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.