Bug 2369

Summary: VirtualBox udev rules break printing to USB printers
Product: Fedora Reporter: Ilja Sekler <bugzilla.i.sekler>
Component: VirtualBoxAssignee: Sérgio Basto <sergio>
Status: RESOLVED FIXED    
Severity: normal CC: lxtnow, sergio
Priority: P5    
Version: 17   
Hardware: All   
OS: GNU/Linux   
namespace:

Description Ilja Sekler 2012-06-08 20:55:57 CEST
The file VirtualBox-OSE-90-vboxdrv.rules supplied by the packager and referenced in VirtualBox.spec:27 as Source3 breaks printing to USB printers exactly like in <https://bugzilla.novell.com/show_bug.cgi?id=609424>. This issue is fixed over a year ago upstream:

<https://www.virtualbox.org/ticket/7759>

Maybe it would be helpful to look at <http://ftp.de.debian.org/debian/pool/main/v/virtualbox/virtualbox_4.1.16-dfsg-1.debian.tar.gz> how it is solved in Debian, which ships also the helper script /lib/udev/VBoxCreateUSBNode.sh?
Comment 1 Sérgio Basto 2012-06-08 23:06:11 CEST
Hi, 
thanks, for bug report 
what about add this: 

ACTION=="add", SUBSYSTEM=="usb_device", GROUP="vboxusers", MODE="0664

to /etc/udev/rules.d/90-vboxdrv.rules ? 

after do as root: 
/sbin/udevadm control --reload-rules 
systemctl restart udev-trigger.service
ystemctl restart udev-settle.service


Seems to me, that we just have one of the USB rules, but if you could test it would be a great help.

Also many pages , if you have any patch for solution will be welcomed .

Thanks,
Comment 2 Ilja Sekler 2012-06-09 00:04:15 CEST
(In reply to comment #1)

> what about add this: 
> 
> ACTION=="add", SUBSYSTEM=="usb_device", GROUP="vboxusers", MODE="0664
> 
> to /etc/udev/rules.d/90-vboxdrv.rules ? 

No joy, the device must be writable for the group "lp" to print, read permissions for the world are not enough.

> [...] if you have any patch for solution will be welcomed .

I wish I could just provide a patch, but unfortunately this is beyond my capabilities. Nevertheless, I hope that you could possibly adopt the upstream approach from VirtualBox-4.1.16/src/VBox/Installer/linux/installer-utils.sh and VirtualBox-4.1.16/src/VBox/Installer/linux/VBoxCreateUSBNode.sh.

Thanks!
Comment 3 Sérgio Basto 2012-06-09 02:25:48 CEST
(In reply to comment #2)

ok , so may you try add this line instead the other on comment before:

ACTION=="add", SUBSYSTEM=="usb_device", GROUP="vboxusers", MODE="066" SYMLINK+="vboxusb/$env{BUSNUM}/$env{DEVNUM}"

and restart udev, as root: 
/sbin/udevadm control --reload-rules 
systemctl restart udev-trigger.service
ystemctl restart udev-settle.service

> I hope that you could possibly adopt the upstream
> approach from VirtualBox-4.1.16/src/VBox/Installer/linux/installer-utils.sh and
> VirtualBox-4.1.16/src/VBox/Installer/linux/VBoxCreateUSBNode.sh.


VBoxCreateUSBNode.sh is adopted (I think) ...
Comment 4 Ilja Sekler 2012-06-09 09:47:15 CEST
(In reply to comment #3)

> (In reply to comment #2)
> 
> ok , so may you try add this line instead the other on comment before:
> 
> ACTION=="add", SUBSYSTEM=="usb_device", GROUP="vboxusers", MODE="066"
> SYMLINK+="vboxusb/$env{BUSNUM}/$env{DEVNUM}"

I don't really get the reason for zero permissions for the owner, but anything world-writable works, I tested this yesterday as well. But why would anyone want USB devices to be freely accessible for everyone?

>> I hope that you could possibly adopt the upstream approach from 
>> VirtualBox-4.1.16/src/VBox/Installer/linux/installer-utils.sh and
>> VirtualBox-4.1.16/src/VBox/Installer/linux/VBoxCreateUSBNode.sh. 
> 
> VBoxCreateUSBNode.sh is adopted (I think) ...

Unfortunately not (BTW, upstream doesn't add symlinks). I can confirm, that putting VBoxCreateUSBNode.sh into /lib/udev/ and

SUBSYSTEM=="usb_device", ACTION=="add", RUN+="VBoxCreateUSBNode.sh $major $minor $attr{bDeviceClass} vboxusers"

SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", RUN+="VBoxCreateUSBNode.sh $major $minor $attr{bDeviceClass} vboxusers"

SUBSYSTEM=="usb_device", ACTION=="remove", RUN+="VBoxCreateUSBNode.sh --remove $major $minor"

SUBSYSTEM=="usb", ACTION=="remove", ENV{DEVTYPE}=="usb_device", RUN+="VBoxCreateUSBNode.sh --remove $major $minor"

udev rules work fine on Fedora 17.
Comment 5 Sérgio Basto 2012-06-09 14:32:05 CEST
(In reply to comment #4)
> Unfortunately not (BTW, upstream doesn't add symlinks). I can confirm, that
> putting VBoxCreateUSBNode.sh into /lib/udev/ and
> 
> SUBSYSTEM=="usb_device", ACTION=="add", RUN+="VBoxCreateUSBNode.sh $major
> $minor $attr{bDeviceClass} vboxusers"
> 
> SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device",
> RUN+="VBoxCreateUSBNode.sh $major $minor $attr{bDeviceClass} vboxusers"
> 
> SUBSYSTEM=="usb_device", ACTION=="remove", RUN+="VBoxCreateUSBNode.sh --remove
> $major $minor"
> 
> SUBSYSTEM=="usb", ACTION=="remove", ENV{DEVTYPE}=="usb_device",
> RUN+="VBoxCreateUSBNode.sh --remove $major $minor"
> 
> udev rules work fine on Fedora 17.

Did your printer worked ? that is a good new 

Thanks,
Comment 6 Sérgio Basto 2012-06-09 17:56:04 CEST
(In reply to comment #4)
> I can confirm, that
> putting VBoxCreateUSBNode.sh into /lib/udev/ and
> 
> SUBSYSTEM=="usb_device", ACTION=="add", RUN+="VBoxCreateUSBNode.sh $major
> $minor $attr{bDeviceClass} vboxusers"
> 
> SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device",
> RUN+="VBoxCreateUSBNode.sh $major $minor $attr{bDeviceClass} vboxusers"
> 
> SUBSYSTEM=="usb_device", ACTION=="remove", RUN+="VBoxCreateUSBNode.sh --remove
> $major $minor"
> 
> SUBSYSTEM=="usb", ACTION=="remove", ENV{DEVTYPE}=="usb_device",
> RUN+="VBoxCreateUSBNode.sh --remove $major $minor"
> 
> udev rules work fine on Fedora 17.

Nice ! , you just fixed all udev hardware rules, not just printer :) 

Many thanks,
Comment 7 Ilja Sekler 2012-06-09 21:29:54 CEST
Just to get things right: these udev rules for USB devices originate from already mentioned VirtualBox-4.1.16/src/VBox/Installer/linux/installer-utils.sh. They are used also by Arch <https://projects.archlinux.org/svntogit/community.git/tree/trunk/10-vboxdrv.rules?h=packages/virtualbox> and Debian.

If Fedora doesn't need ACL for the /dev/vboxdrv node (Arch added ACL in <https://bugs.archlinux.org/task/18005>), the KERNEL rule is IMHO redundant, but all USB rules from the Arch package are aligned with upstream and work correctly for me on Fedora 17 so I can print to my HP USB inkjet printer from the host and from VirtualBox guests.

It would be great if you could package VBoxCreateUSBNode.sh and 10-vboxdrv.rules like upstream and in Arch (and in Debian, but Debian puts these udev rules into 60-virtualbox.rules, which is not what upstream does). Not sure how to handle the present file /etc/udev/rules.d/90-vboxdrv.rules - installing a fixed VirtualBox package won't fix USB printing unless this file is deleted.

Thanks!
Comment 8 Sérgio Basto 2012-06-10 15:15:15 CEST
Hi 
you may test it 

add this to /etc/yum.repos.d/rpmfusion-free-updates-testing.repo

[rpmfusion-free-needsign]
name=RPM Fusion for Fedora $releasever - Free - Need Sign
baseurl=http://buildsys.rpmfusion.org/plague-results/fedora-$releasever-rpmfusion_free/
enabled=0
gpgcheck=0

and do: 
yum --enablerepo=rpmfusion-free-needsign clean all
yum --enablerepo=rpmfusion-free-needsign update VirtualBox

or wait for pushing to rpmfusion-free-updates-testing 
and do:
yum --enablerepo=rpmfusion-free-updates-testing clean all
yum --enablerepo=rpmfusion-free-updates-testing update VirtualBox

Thanks,
Comment 9 Ilja Sekler 2012-06-10 17:38:04 CEST
This is great. I've built locally and installed the VirtualBox rpm from VirtualBox-4.1.16-3.fc17.src.rpm and can confirm that the bug is fixed.

I don't know the exact reason why VirtualBox developers placed their udev rules that far down the stack (10-*.rules), but I'm also not aware of any adverse effects of putting them close to the top like in Fedora (90-*.rules), so no objections to keeping the file name :-)

Looking forward to see the updated package in rpmfusion-free-updates-testing.

Thanks a lot!
Comment 10 Ilja Sekler 2012-06-16 13:48:26 CEST
Verified FIXED by VirtualBox-4.1.16-3.fc17.x86_64 from rpmfusion-free-updates-testing (meanwhile already in rpmfusion-free-updates).

Thanks!