diff --git a/system_files/shared/usr/lib/udev/rules.d/70-usb-printer-uaccess.rules b/system_files/shared/usr/lib/udev/rules.d/70-usb-printer-uaccess.rules new file mode 100644 index 000000000..612e321c5 --- /dev/null +++ b/system_files/shared/usr/lib/udev/rules.d/70-usb-printer-uaccess.rules @@ -0,0 +1,8 @@ +# Give the active seat user read/write access to USB printers. +# systemd leaves a USB printer's node as root:lp 0664, and nobody is in lp on a +# default install, so a printer application running as the user (rootless +# container) can open the printer but not send it a job. uaccess adds a seat +# ACL for the logged-in user on top; lp keeps its access, so no MODE or GROUP. +# 0701 is the USB printer interface class. +# https://github.com/projectbluefin/common/issues/1681 +SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:0701??:*", TAG+="uaccess" diff --git a/tests/test_udev_rules.bats b/tests/test_udev_rules.bats index 0668e3e40..882729f8b 100644 --- a/tests/test_udev_rules.bats +++ b/tests/test_udev_rules.bats @@ -10,6 +10,8 @@ RULES_DIR="$BATS_TEST_DIRNAME/../system_files/shared/usr/lib/udev/rules.d" VIIA_RULES="${RULES_DIR}/70-viia.rules" +# Issue #1681: rootless printer apps need write access to USB printer nodes. +PRINTER_RULES="${RULES_DIR}/70-usb-printer-uaccess.rules" # Print the rule lines (comments and blanks stripped) of a rules file. _rule_lines() { @@ -33,6 +35,26 @@ _rule_lines() { [[ "$output" != *'MODE'* ]] } +@test "70-usb-printer-uaccess.rules exists in the shared system files" { + [ -f "${PRINTER_RULES}" ] +} + +@test "70-usb-printer-uaccess.rules tags USB printer-class devices with uaccess" { + run _rule_lines "${PRINTER_RULES}" + [ "$status" -eq 0 ] + [[ "$output" == *'SUBSYSTEM=="usb"'* ]] + [[ "$output" == *'ENV{DEVTYPE}=="usb_device"'* ]] + [[ "$output" == *'ENV{ID_USB_INTERFACES}=="*:0701??:*"'* ]] + [[ "$output" == *'TAG+="uaccess"'* ]] +} + +@test "70-usb-printer-uaccess.rules leaves MODE and GROUP to systemd" { + run _rule_lines "${PRINTER_RULES}" + [ "$status" -eq 0 ] + [[ "$output" != *'MODE'* ]] + [[ "$output" != *'GROUP'* ]] +} + @test "uaccess rules sort before systemd's 73-seat-late.rules" { local late="" local f