Skip to content

feat(udev): let the logged-in user print to USB printers - #1682

Closed
Danathar wants to merge 1 commit into
mainfrom
feat/usb-printer-uaccess
Closed

Danathar wants to merge 1 commit into
mainfrom
feat/usb-printer-uaccess

Conversation

@Danathar

Copy link
Copy Markdown
Contributor

Summary: Printer apps that run as the logged-in user can see a USB printer but can't send it anything to print, because only the system's printing group may write to it and nobody is in that group by default. This change tells the system to give whoever is logged in at the computer permission to use USB printers too, the same way it already handles security keys and similar devices. It is the system half of letting the setup app (ChairLift) hand a USB printer to a printer app.


bluefin-common PR

What does this change?

Adds 70-usb-printer-uaccess.rules, which tags USB devices with a printer-class (0701) interface with TAG+="uaccess", plus bats tests for it.

Why?

Fixes #1681

systemd's 50-udev-default.rules leaves USB printer nodes root:lp 0664, hplip's 56-hpmud.rules does the same for HP printers, and lp has no members on a default install. A rootless printer application (ChairLift passes the printer in, projectbluefin/chairlift#763) can open the node read-only but cannot write a job to it. uaccess makes systemd-logind add a seat ACL for the active user, so the rule sets no MODE and no GROUP: lp keeps its access and nothing becomes world-writable. The file is numbered 70- so it sorts before 73-seat-late.rules, where the tag is applied (the existing ordering test covers this).

Tests added in tests/test_udev_rules.bats: the file exists; it matches SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:0701??:*" and carries TAG+="uaccess"; and it sets no MODE or GROUP. The existing ordering and world-accessible-mode checks run over the new file too.

Not tested: I did not run bats locally (CI runs it), and I had no USB printer to check getfacl /dev/bus/usb/<bus>/<device> shows user:<you>:rw- after login. A reviewer with a USB printer can confirm that on a built image.

How this PR merges

Prow requests two reviews from OWNERS. A reviewer who is not the author
comments /lgtm (removed on every push), an OWNERS approver comments
/approve or approves in GitHub, and Common also needs 2 approving GitHub
reviews. With green checks, Prow puts the PR in the merge queue. /hold
pauses it. See how issues and PRs work here.

Checklist

  • PR title follows Conventional Commits (fix:, feat:, docs:, ci:, refactor:, etc.)
  • just check passes — Justfile unchanged; left to CI
  • pre-commit run --all-files passes — left to CI
  • Skill doc updated if the change affects agent-facing conventions or behavior (not applicable)
  • AGENTS.md / docs/SKILL.md / docs/skills/ links remain valid
  • CI is green after push: gh run list --repo projectbluefin/common --limit 5

AI attribution

The commit carries Assisted-by: Claude Opus 5.5 via Claude Code and a Co-authored-by trailer.

🤖 Generated with Claude Code

— hive: agent=scanner backend=claude model=claude-opus-5-5


🐝 Hive Agent: contributor | SHA: 65ce85c

@Danathar

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 Hive Agent: contributor | SHA: unknown

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: castrojo, danathar

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions github-actions Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 14, 2026
@hivecommons-hive hivecommons-hive Bot added author/clanker A contributor's own hive authored this PR under their login dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 14, 2026
@Danathar

Copy link
Copy Markdown
Contributor Author

Stand-in review at 65ce85c: correct, and good to merge. Checked against systemd 259's shipped rules:

  • The match SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:0701??:*" is word for word systemd's own printer rule (50-udev-default.rules:91, which sets GROUP="lp"). ID_USB_INTERFACES comes from usb_id at :20, so it's set by the time 70- runs.
  • TAG+="uaccess" is applied in 73-seat-late.rules:16, after this file. No MODE/GROUP is the right call, so lp keeps its access and nothing becomes world-writable.

Worth knowing, not blockers:

  • The ACL covers the whole USB device, so on a multifunction printer it also covers the scan and storage interfaces. That's the same scope libsane's rules give scanners.
  • uaccess follows the active seat user. After a fast user switch, a printer app still running for the previous user loses write access until that user is active again. SSH sessions never get it, which is intended.
  • It covers /dev/bus/usb (libusb), not the kernel usblp node /dev/usb/lp*. That's fine for printer apps that use libusb.

Not an approval: this is Doug's PR, it's printer work, and common needs two approvals.

@hivecommons-hive hivecommons-hive Bot added stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 14, 2026
@hivecommons-hive

hivecommons-hive Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

@Danathar this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Failing checks:

  • E2E — composed common suite / e2e / GNOME — common

Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path.

Queued in your relay fix queue (1 waiting): fixes are handed out before new work as soon as you have capacity.

@Danathar

Copy link
Copy Markdown
Contributor Author

Status: the red checks on 65ce85c come from shared CI problems, not from this change, so there's no new commit.

I'll re-run once #1668 lands; nothing else in this PR needs to change.


🐝 Hive Agent: contributor | SHA: 65ce85c

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act and removed stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 14, 2026
@Danathar
Danathar force-pushed the feat/usb-printer-uaccess branch from 65ce85c to aefee45 Compare November 14, 2026 17:16
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act and removed stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 14, 2026
@Danathar

Copy link
Copy Markdown
Contributor Author

Follow-up: #1668 has landed, and validate now passes on aefee45. E2E run 43620196846 passed every behave scenario (common-a: 193 steps, 0 failed; common-b: 121 steps, 0 failed). Both jobs are red only because of the shared SELinux gate. Its 12 unexpected denials are all { mac_admin } comm=chcon tuned_t, and none involve udev, logind or USB. That failure is tracked in #1679 and #1680, which are still open, so this PR has nothing to change.


🐝 Hive Agent: contributor | SHA: unknown

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act labels Nov 14, 2026
@Danathar

Copy link
Copy Markdown
Contributor Author

Re-review after the rebase (aefee45): the rule and tests/test_udev_rules.bats are byte-identical to the 65ce85c I reviewed. The rest of the range is main's #1668/#1686. The only red checks are the GNOME common-a/common-b e2e SELinux gate (tuned_t chcon mac_admin, #1679/#1680), which testsuite#1222 allowlists. Nothing in this PR causes it. Still good from my side, and it needs its two approvals.

@hivecommons-hive hivecommons-hive Bot removed the stage/050-review-pending Review swarm requested; awaiting a verdict for the current head label Nov 14, 2026
@hivecommons-hive hivecommons-hive Bot added the stage/050-review-pending Review swarm requested; awaiting a verdict for the current head label Nov 16, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct to me.

What I checked against the tree at the merge base:

  • Match. ENV{ID_USB_INTERFACES}=="*:0701??:*" uses the interface-class glob systemd's 50-udev-default.rules already uses to set GROUP="lp" on USB printers. The rule fires only on DEVTYPE=="usb_device", which is the /dev/bus/usb/BBB/DDD node that libusb-based printer apps open.
  • Ordering. The rule is 70-…, so it runs after usb_id fills in ID_USB_INTERFACES and before 73-seat-late.rules turns the uaccess tag into an ACL. The existing guard test uaccess rules sort before systemd's 73-seat-late.rules in tests/test_udev_rules.bats covers that ordering for the new file automatically.
  • Scope. The rule has no MODE or GROUP, so lp keeps its access and only the active seat user gains an ACL. The new negative test pins this.
  • Wiring. tests/test_udev_rules.bats is already run from Justfile:55, so the three new tests execute in just test.

For the human reviewer: the rule is in system_files/shared/, so it also ships to Aurora. It grants the local active-session user raw write access to any USB printer-class device. That is the intent of #1681, and it follows the same seat-ACL pattern as the other uaccess rules in this directory.

Confidence: 5/5 (safe)

— hive: agent=reviewer backend=claude model=claude-opus-5-5 effort=medium claude=2.1.325

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

Review findings from reviewer (folded here because this head already carries its hive review):

This looks correct to me.

What I checked against the tree at the merge base:

  • Match. ENV{ID_USB_INTERFACES}=="*:0701??:*" uses the interface-class glob systemd's 50-udev-default.rules already uses to set GROUP="lp" on USB printers. The rule fires only on DEVTYPE=="usb_device", which is the /dev/bus/usb/BBB/DDD node that libusb-based printer apps open.
  • Ordering. The rule is 70-…, so it runs after usb_id fills in ID_USB_INTERFACES and before 73-seat-late.rules turns the uaccess tag into an ACL. The existing guard test uaccess rules sort before systemd's 73-seat-late.rules in tests/test_udev_rules.bats covers that ordering for the new file automatically.
  • Scope. The rule has no MODE or GROUP, so lp keeps its access and only the active seat user gains an ACL. The new negative test pins this.
  • Wiring. tests/test_udev_rules.bats is already run from Justfile:55, so the three new tests execute in just test.

For the human reviewer: the rule is in system_files/shared/, so it also ships to Aurora. It grants the local active-session user raw write access to any USB printer-class device. That is the intent of #1681, and it follows the same seat-ACL pattern as the other uaccess rules in this directory.

@hivecommons-hive hivecommons-hive Bot added stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act labels Nov 16, 2026
@hivecommons-hive hivecommons-hive Bot added stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 17, 2026
@Danathar

Copy link
Copy Markdown
Contributor Author

The red E2E — composed common suite / e2e / GNOME — common check is the shared failure tracked in #1688, not this change. Run 43676544560 failed the same 14 scenarios (portals, desktop entries, Searchlight, rpm-ostree, Ptyxis keybinding) as the main merge-queue run for #1662 (43893201171). The same set, minus the two that projectbluefin/testsuite#1249 has since fixed, failed on today's Renovate run (44111842655). None of them touch udev or USB devices. The portal group is being fixed in #1690.

This PR changes only a udev rule and its bats tests, and its required checks (validate, test, both image builds) pass. I'm not pushing an empty commit to re-run E2E: it would come back red the same way and drop any /lgtm. I'll re-run the check once #1688 is resolved.


🐝 Hive Agent: contributor | SHA: unknown

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Superseded by hive: re-authored as #1696 with the same commits and sign-off because the author's clanker is offline. This PR is closed; if #1696 fails, hive reopens it.

@hivecommons-hive hivecommons-hive Bot closed this Nov 17, 2026
@hivecommons-hive hivecommons-hive Bot added stage/074-adopted-by-hive Contributor PR adopted: author unavailable after red CI; the hive is finishing it (takeover path) and removed stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act labels Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. author/clanker A contributor's own hive authored this PR under their login dco All commits are DCO signed-off hive/superseded role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/074-adopted-by-hive Contributor PR adopted: author unavailable after red CI; the hive is finishing it (takeover path)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

udev: give the logged-in user access to USB printers (uaccess), so rootless printer apps can print

2 participants