From 590a6441e397ef318e8877e178415b214ff46a8c Mon Sep 17 00:00:00 2001 From: Danathar Date: Sat, 14 Nov 2026 14:31:48 +0000 Subject: [PATCH] feat(udev): give the logged-in user access to USB printers A USB printer's node is root:lp 0664 and nobody is in lp on a default install, so a printer application running as the user can read the printer but not send it a job. Tag USB printer-class (0701) devices with uaccess so the active seat user gets an ACL; lp keeps its access. Fixes #1681 Hive-Run: projectbluefin/common#1681 Hive-Plan: issue-1681 Hive-Spec: issue-1681#what-to-do Assisted-by: Claude Opus 5.5 via Claude Code Co-authored-by: Claude Opus 5.5 Signed-off-by: Danathar --- .../udev/rules.d/70-usb-printer-uaccess.rules | 8 +++++++ tests/test_udev_rules.bats | 22 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 system_files/shared/usr/lib/udev/rules.d/70-usb-printer-uaccess.rules 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