Package: system-config-printer-udev
Version: 1.5.18-1
Severity: important
X-Debbugs-Cc: [email protected],
[email protected],
[email protected]
Greetings system-config-printer-udev Maintainers and Other Recipients,
This message contains:
- a bug report about the Debian package ~system-config-printer-udev~
not supporting printer hotplug without ~systemd~ running as init
- a patch to the udev rule ~70-printers.rules~ to support printer
hotplug with ~systemd~ and other init systems
Contents:
- Other Recipients
- Personal Background
- Steps to Reproduce
- Research
- Patch
- Rationale
- Conclusion
- References
- System Information
- Attachments
- 0001-update-udev-rule-to-support-hotplug-without-systemd.patch
- 70-printers.rules
Other Recipients:
I have verified that ~70-printers.rules~ is identical in the upstream
repository (branch ~origin/master~ commit ~aa511d29~) [1], the Debian
package repository (branch ~debian/latest~ commit ~4b21a14f~ tag
~debian/1.5.18-4~) [2], and the Debian 12 (Bookworm) source package
~system-config-printer-udev~ version ~1.5.18-1~ [3], so I hope you don't
mind me copying upstream on this.
I have also copied this to
[email protected]~ because I imagine it will
also interest supporters of init diversity in Debian.
Personal Background:
I have been using Debian on the desktop since Debian 4 (Etch). I always
used the default init system, and the switch to ~systemd~ in Debian 8
(Jessie) was transparent for my use case. Recently I decided to explore
alternative init systems on my Debian 12 (Bookworm) system running the
MATE Desktop Environment, and I found that switching to ~sysvinit~ was
surprisingly painless [4][5].
The only problem I noticed was that printer hotplug didn't work with
~system-config-printer~ under ~sysvinit~. I am using a Brother HLL2300D
laser printer connected via USB with the Brother drivers [6], however I
have observed the same problem with the drivers in the Debian package
~printer-driver-brlaser~ [7]. I found that the problem relates to the
~udev~ rules in the package ~system-config-printer-udev~, so this bug is
expected to affect any printer using that package under ~sysvinit~ and
any other init system besides ~systemd~.
Steps to Reproduce:
I. Install and configure printer
- steps will vary based on printer
- as mentioned in "Personal Background" (above), I am using:
- Debian 12 (Bookworm) with the MATE Desktop Environment
- a Brother HLL2300D laser printer connected via USB with the
Brother drivers [6]
II. Bug
1. observe that printer hotplug works by default under ~systemd~
- when the printer is connected:
- ~lsusb~ will show a line for the printer like
~Bus 002 Device 005: ID 04f9:0061 Brother Industries, Ltd
HL-L2300D series~
- ~system-config-printer~ will show the "Printer State" as
"Idle"
- when the printer is disconnected:
- ~lsusb~ will show no line for the printer
- ~system-config-printer~ will show the "Printer State" as
"Stopped - Unplugged or turned off"
- plugging and unplugging the USB or cycling the printer power
will alternate between these states
2. observe that printer hotplug does not work after installing and
booting under ~sysvinit~ [4][5]:
- if the printer was connected at boot, or if the printer and
driver was uninstalled and reinstalled:
- ~lsusb~ will show a line for the printer like
~Bus 002 Device 005: ID 04f9:0061 Brother Industries, Ltd
HL-L2300D series~
- ~system-config-printer~ will show the "Printer State" as
"Idle"
- if the printer was not connected at boot, or if the printer
and driver was uninstalled and reinstalled and then powered
off:
- ~lsusb~ will show no line for the printer
- ~system-config-printer~ will show the "Printer State" as
"Stopped - Unplugged or turned off"
- plugging and unplugging the USB or cycling the printer power
will change the state of ~lsusb~ but not
~system-config-printer~
III. Fix
1. apply the patch (below) to ~70-printers.rules~ and install it to
~/etc/udev/rules.d/70-printers.rules~ to override the default in
~/usr/lib/udev/rules.d/70-printers.rules~
- run ~udevadm control --reload-rules~ to use the new rules
- see the output of
~udevadm test --action=add /dev/bus/usb/XXX/YYY~
to confirm which rules are applied
2. observe that printer hotplug works with patch under ~sysvinit~
- as described in II.1 (above)
3. observe that printer hotplug works with patch under ~systemd~
- as described in II.1 (above)
Research:
After various unsuccessful attempts to diagnose and fix the problem, and
after a lot of web searches, I found a post on the Dev1 Galaxy (Devuan)
Forum [8] that pointed me towards a solution.
The ~udev~ "add" rule in line 4 of the current version of
~70-printers.rules~ calls the ~systemd~ service
[email protected]~ which in turn calls
~udev-configure-printer~. According to
~git log -L4,4:udev/70-printers.rules~, this change was made in commits
~c05d2746~, ~aa746792~, and ~cab2d001~.
No hard dependency on ~systemd~ is declared by
~system-config-printer-udev~ or ~udev~ itself in either Debian 12
(Bookworm) or Debian 13 (Trixie) (in Trixie the ~systemd~ dependency can
be satisfied by ~systemd-standalone-sysusers~ or ~systemd-sysusers~)
[9][10][11][12].
~system-config-printer~ uses the conditional ~HAVE_SYSTEMD~ to test for
the presence of ~systemd~ at compile-time. Several examples of the
~HAVE_SYSTEMD~ variable appear in the daemon(7) manpage [13]. Looking at
the source I can't tell offhand whether or how this is used to switch
between ~systemd~ and non-~systemd~ functionality, but since it happens
at compile-time it cannot be used to support different init systems at
run-time.
According to the sd_booted(3) manpage, the correct way to determine
whether ~systemd~ running as init is to test for the existence of the
directory ~/run/systemd/system~ [14][15][16].
According to the udev(7) manpage, the ~TEST~ key can be used to test for
the existence or nonexistence of a file [17].
Patch:
Putting together all the "Research" documented above, we can make
~70-printers.rules~ support ~systemd~ and other init systems by testing
for the existence of ~/run/systemd/system~ and calling either
[email protected]~ or ~udev-configure-printer~ as appropriate.
Please find attached a patch against commit ~895d3dec~ (tag ~v1.5.18~)
that implements this change, as well as a copy of the entire file.
Rationale:
- The Debian package ~system-config-printer-udev~ does not declare a
hard dependency on ~systemd~ but currently uses functionality
exclusive to ~systemd~
- ~system-config-printer~ tests for ~HAVE_SYSTEMD~ at compile-time,
suggesting it does not make assumptions about the init system
- the proposed patch makes ~system-config-printer-udev~ support printer
hotplug for users of alternate init systems while not affecting users
of ~systemd~
Conclusion:
Thank you for taking the time to review this bug report and for
considering my proposed patch.
Regards,
Taylor Alexander Brown
References:
[1] https://github.com/OpenPrinting/system-config-printer
[2] https://salsa.debian.org/gnome-team/system-config-printer.git
[3] https://packages.debian.org/bookworm/system-config-printer-udev
[4] https://wiki.debian.org/Init
[5] https://ianlecorbeau.com/blog/debian-bookworm-sysvinit.html
[6]
https://support.brother.com/g/b/producttop.aspx?c=us&lang=en&prod=hll2300d_us_eu_as
[7] https://packages.debian.org/bookworm/printer-driver-brlaser
[8] https://dev1galaxy.org/viewtopic.php?id=4819
[9] https://packages.debian.org/bookworm/system-config-printer-udev
[10] https://packages.debian.org/trixie/system-config-printer-udev
[11] https://packages.debian.org/bookworm/udev
[12] https://packages.debian.org/trixie/udev
[13] https://manpages.debian.org/bookworm/systemd/daemon.7.en.html
[14] https://manpages.debian.org/bookworm/libsystemd-dev/sd_booted.3.en.html
[15]
https://superuser.com/questions/1017959/how-to-know-if-i-am-using-systemd-on-linux/1631444#1631444
[16]
https://unix.stackexchange.com/questions/18209/detect-init-system-using-the-shell/164092#164092
[17] https://manpages.debian.org/bookworm/udev/udev.7.en.html
-- System Information:
Debian Release: 12.13
APT prefers oldstable-security
APT policy: (500, 'oldstable-security'), (500, 'oldstable')
Architecture: amd64 (x86_64)
Kernel: Linux 6.1.0-44-amd64 (SMP w/1 CPU thread; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE
not set
Shell: /bin/sh linked to /usr/bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled
Versions of packages system-config-printer-udev depends on:
ii libc6 2.36-9+deb12u13
ii libcups2 2.4.2-3+deb12u9
ii libglib2.0-0 2.74.6-2+deb12u8
ii libudev1 252.39-1~deb12u1
ii libusb-1.0-0 2:1.0.26-1
ii python3 3.11.2-1+b1
ii python3-cups 2.0.1-5+b4
ii python3-cupshelpers 1.5.18-1
ii python3-dbus 1.3.2-4+b1
system-config-printer-udev recommends no packages.
system-config-printer-udev suggests no packages.
-- no debconf information
# UDEV rules for USB devices - ENV variables can be monitored
# via 'sudo udevadm monitor --udev --subsystem-match=usb --property'
# Low-level USB device add trigger
#
## run as a systemd service if systemd is running
#
# per sd_booted(3), the correct way to test whether the system is running the
# systemd init system is to check whether the directory /run/systemd/system
exists
#
TEST=="/run/systemd/system" \
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device",
ENV{ID_USB_INTERFACES}=="*:0701??:*", ENV{ID_USB_INTERFACES}!="*:070104:*",
TAG+="systemd",
ENV{SYSTEMD_WANTS}="configure-printer@usb-$env{BUSNUM}-$env{DEVNUM}.service"
#
## otherwise call udev-configure-printer directly
#
TEST!="/run/systemd/system" \
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device",
ENV{ID_USB_INTERFACES}=="*:0701??:*", ENV{ID_USB_INTERFACES}!="*:070104:*",
RUN+="udev-configure-printer add %p"
#
# Low-level USB device remove trigger
# Interface types:
# 7/1/1 - device with unidirectional USB, managed by usb backend
# 7/1/2 - device with bidirectional USB, managed by usb backend
# 7/1/3 - device with special USB protocol, managed by hp backend
# 7/1/4 - device with IPP over USB protocol, managed by ipp-usb daemon
ACTION=="remove", SUBSYSTEM=="usb", ENV{INTERFACE}=="7/1/*",
ENV{INTERFACE}!="7/1/4", RUN+="udev-configure-printer remove %p"
>From 81c744ad3c0795776205a938d03c002d9514874d Mon Sep 17 00:00:00 2001
From: Taylor Alexander Brown <[email protected]>
Date: Sat, 28 Mar 2026 21:19:57 -0700
Subject: [PATCH 1/1] update udev rule to support hotplug without systemd
---
udev/70-printers.rules | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/udev/70-printers.rules b/udev/70-printers.rules
index 433b8c8c..6297cc92 100644
--- a/udev/70-printers.rules
+++ b/udev/70-printers.rules
@@ -1,7 +1,20 @@
# UDEV rules for USB devices - ENV variables can be monitored
# via 'sudo udevadm monitor --udev --subsystem-match=usb --property'
# Low-level USB device add trigger
+#
+## run as a systemd service if systemd is running
+#
+# per sd_booted(3), the correct way to test whether the system is running the
+# systemd init system is to check whether the directory /run/systemd/system exists
+#
+TEST=="/run/systemd/system" \
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:0701??:*", ENV{ID_USB_INTERFACES}!="*:070104:*", TAG+="systemd", ENV{SYSTEMD_WANTS}="configure-printer@usb-$env{BUSNUM}-$env{DEVNUM}.service"
+#
+## otherwise call udev-configure-printer directly
+#
+TEST!="/run/systemd/system" \
+ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:0701??:*", ENV{ID_USB_INTERFACES}!="*:070104:*", RUN+="udev-configure-printer add %p"
+#
# Low-level USB device remove trigger
# Interface types:
# 7/1/1 - device with unidirectional USB, managed by usb backend
--
2.39.5