udev: detect USB smartcard readers through the usb-interface hwdb

Instead of setting ID_SMARTCARD_READER from a direct match on
ID_USB_INTERFACES in 60-fido-id.rules, set it for devices exposing a
smartcard (CCID) interface, i.e. interface class 0b, in the usb-interface
hwdb.

The hwdb lookup is done in 50-udev-default.rules.in, which is processed
before 60-fido-id.rules, so the subsequent rules that match on
ID_SMARTCARD_READER are not affected.

As the property can be set to either 0 or 1 in the hwdb, make the rules in
70-uaccess.rules.in and 99-systemd.rules.in match on "1" instead of any
non-empty value.

This makes the property, and the tags and the target depending on it,
require hwdb.bin, which matters when a smartcard reader is already used in
the initrd. Mention that in NEWS.
This commit is contained in:
Yu Watanabe committed 2026-10-31 23:07:06 +09:00
1 parent 82d27c00b7
commit 1995a41d7c
6 files changed
+19 -3

No files matched your search

+9
View File
@@ -150,6 +150,15 @@ CHANGES WITH 263 in spe:
adds rustc >= 1.85, bindgen >= 0.71.1 and meson >= 1.4.0 as
optional build dependencies.
* The ID_SMARTCARD_READER udev property for USB smartcard (CCID)
readers is now set through the udev hwdb instead of by a udev rule
that directly matches the USB interfaces. If a smartcard reader is
already used in the initrd, e.g. by systemd-cryptsetup to activate
encrypted host disks, the initrd must now include hwdb.bin.
Otherwise, the reader does not get the property and
systemd-cryptsetup may not find the device, so the activation may no
longer work.
Changes in the system and service manager:
* LockPersonality= no longer refuses querying the personality with
+7
View File
@@ -18,6 +18,9 @@
#
# Specify if a device is a printer
# ID_PRINTER=0|1
#
# Specify if a device is a smartcard reader
# ID_SMARTCARD_READER=0|1
# USB3 Vision devices exposing the device control interface
usb-interface:v*p*:ef0500:*
@@ -27,3 +30,7 @@ usb-interface:v*p*:ef0500:*
# Printers (interface class 07, subclass 01)
usb-interface:v*p*:0701??:*
ID_PRINTER=1
# Smartcard readers (interface class 0b, CCID)
usb-interface:v*p*:0b????:*
ID_SMARTCARD_READER=1
+1
View File
@@ -222,6 +222,7 @@ def property_grammar():
('ID_LINK_DIR', Word(alphanums + '-_')),
('ID_USB3_VISION', zero_one),
('ID_PRINTER', zero_one),
('ID_SMARTCARD_READER', zero_one),
('POINTINGSTICK_SENSITIVITY', INTEGER),
('ID_INTEGRATION', Or(('internal', 'external'))),
('ID_INPUT_TOUCHPAD_INTEGRATION', Or(('internal', 'external'))),
-1
View File
@@ -7,7 +7,6 @@ SUBSYSTEM=="hidraw", IMPORT{program}="fido_id"
# Tag any form of security token as such
ENV{ID_SECURITY_TOKEN}=="1", TAG+="security-device"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:0b????:*", ENV{ID_SMARTCARD_READER}="1"
# Tag any CCID device (i.e. Smartcard Reader) as security token
ENV{ID_SMARTCARD_READER}=="1", TAG+="security-device"
+1 -1
View File
@@ -61,7 +61,7 @@ SUBSYSTEM=="misc", KERNEL=="kvm", TAG+="uaccess"
{% endif %}
# smart-card readers
ENV{ID_SMARTCARD_READER}=="?*", TAG+="uaccess"
ENV{ID_SMARTCARD_READER}=="1", TAG+="uaccess"
# (USB) authentication devices
ENV{ID_SECURITY_TOKEN}=="?*", TAG+="uaccess"
+1 -1
View File
@@ -55,7 +55,7 @@ SUBSYSTEM=="net", KERNEL!="lo", TAG+="systemd", ENV{SYSTEMD_ALIAS}+="/sys/subsys
SUBSYSTEM=="bluetooth", TAG+="systemd", ENV{SYSTEMD_ALIAS}+="/sys/subsystem/bluetooth/devices/%k", \
ENV{SYSTEMD_WANTS}+="bluetooth.target", ENV{SYSTEMD_USER_WANTS}+="bluetooth.target"
ENV{ID_SMARTCARD_READER}=="?*", TAG+="systemd", ENV{SYSTEMD_WANTS}+="smartcard.target", ENV{SYSTEMD_USER_WANTS}+="smartcard.target"
ENV{ID_SMARTCARD_READER}=="1", TAG+="systemd", ENV{SYSTEMD_WANTS}+="smartcard.target", ENV{SYSTEMD_USER_WANTS}+="smartcard.target"
TAG=="security-device", TAG+="systemd"
SUBSYSTEM=="sound", KERNEL=="controlC*", TAG+="systemd", ENV{SYSTEMD_WANTS}+="sound.target", ENV{SYSTEMD_USER_WANTS}+="sound.target"