summaryrefslogtreecommitdiffstats
path: root/rules.d
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-05-05 11:42:24 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-05-05 11:51:44 +0200
commit155078c835a00fed264a7b36b06f709d9b57cb1b (patch)
tree4d1d4183b184d7af0554adf4faf45250ee18eea6 /rules.d
parentTODO: add entry about boot entries on the bus (diff)
downloadsystemd-155078c835a00fed264a7b36b06f709d9b57cb1b.tar.xz
systemd-155078c835a00fed264a7b36b06f709d9b57cb1b.zip
meson: move udev rules to rules.d/
Diffstat (limited to 'rules.d')
-rw-r--r--rules.d/70-power-switch.rules15
-rw-r--r--rules.d/70-uaccess.rules.in99
-rw-r--r--rules.d/71-seat.rules.in81
-rw-r--r--rules.d/73-seat-late.rules.in20
-rw-r--r--rules.d/meson.build113
5 files changed, 280 insertions, 48 deletions
diff --git a/rules.d/70-power-switch.rules b/rules.d/70-power-switch.rules
new file mode 100644
index 0000000000..3fb954a4f0
--- /dev/null
+++ b/rules.d/70-power-switch.rules
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+#
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+ACTION=="remove", GOTO="power_switch_end"
+
+SUBSYSTEM=="input", KERNEL=="event*", ENV{ID_INPUT_SWITCH}=="1", TAG+="power-switch"
+SUBSYSTEM=="input", KERNEL=="event*", ENV{ID_INPUT_KEY}=="1", TAG+="power-switch"
+
+LABEL="power_switch_end"
diff --git a/rules.d/70-uaccess.rules.in b/rules.d/70-uaccess.rules.in
new file mode 100644
index 0000000000..a3301be1bc
--- /dev/null
+++ b/rules.d/70-uaccess.rules.in
@@ -0,0 +1,99 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+#
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+ACTION=="remove", GOTO="uaccess_end"
+ENV{MAJOR}=="", GOTO="uaccess_end"
+
+# PTP/MTP protocol devices, cameras, portable media players
+SUBSYSTEM=="usb", ENV{ID_USB_INTERFACES}=="*:060101:*", TAG+="uaccess"
+
+# Digicams with proprietary protocol
+ENV{ID_GPHOTO2}=="?*", TAG+="uaccess"
+
+# SCSI and USB scanners
+ENV{libsane_matched}=="yes", TAG+="uaccess"
+
+# HPLIP devices (necessary for ink level check and HP tool maintenance)
+ENV{ID_HPLIP}=="1", TAG+="uaccess"
+
+# optical drives
+SUBSYSTEM=="block", ENV{ID_CDROM}=="1", TAG+="uaccess"
+SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="4|5", TAG+="uaccess"
+
+# Sound devices
+SUBSYSTEM=="sound", TAG+="uaccess", \
+ OPTIONS+="static_node=snd/timer", OPTIONS+="static_node=snd/seq"
+
+# Webcams, frame grabber, TV cards
+SUBSYSTEM=="video4linux", TAG+="uaccess"
+SUBSYSTEM=="dvb", TAG+="uaccess"
+SUBSYSTEM=="media", TAG+="uaccess"
+
+# industrial cameras, some webcams, camcorders, set-top boxes, TV sets, audio devices, and more
+SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_MIDI}=="1", TAG+="uaccess"
+SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_AUDIO}=="1", TAG+="uaccess"
+SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_VIDEO}=="1", TAG+="uaccess"
+
+# DRI video devices
+SUBSYSTEM=="drm", KERNEL=="card*", TAG+="uaccess"
+{% if GROUP_RENDER_UACCESS %}
+# DRI render nodes
+SUBSYSTEM=="drm", KERNEL=="renderD*", TAG+="uaccess"
+{% endif %}
+{% if DEV_KVM_UACCESS %}
+# KVM
+SUBSYSTEM=="misc", KERNEL=="kvm", TAG+="uaccess"
+{% endif %}
+
+# smart-card readers
+ENV{ID_SMARTCARD_READER}=="?*", TAG+="uaccess"
+
+# (USB) authentication devices
+ENV{ID_SECURITY_TOKEN}=="?*", TAG+="uaccess"
+
+# PDA devices
+ENV{ID_PDA}=="?*", TAG+="uaccess"
+
+# Programmable remote control
+ENV{ID_REMOTE_CONTROL}=="1", TAG+="uaccess"
+
+# joysticks
+SUBSYSTEM=="input", ENV{ID_INPUT_JOYSTICK}=="?*", TAG+="uaccess"
+
+# color measurement devices
+ENV{COLOR_MEASUREMENT_DEVICE}=="?*", TAG+="uaccess"
+
+# DDC/CI device, usually high-end monitors such as the DreamColor
+ENV{DDC_DEVICE}=="?*", TAG+="uaccess"
+
+# media player raw devices (for user-mode drivers, Android SDK, etc.)
+SUBSYSTEM=="usb", ENV{ID_MEDIA_PLAYER}=="?*", TAG+="uaccess"
+
+# software-defined radio communication devices
+ENV{ID_SOFTWARE_RADIO}=="?*", TAG+="uaccess"
+
+# 3D printers, CNC machines, laser cutters, 3D scanners, etc.
+ENV{ID_MAKER_TOOL}=="?*", TAG+="uaccess"
+
+# Protocol analyzers
+ENV{ID_SIGNAL_ANALYZER}=="?*", ENV{DEVTYPE}=="usb_device", TAG+="uaccess"
+
+# rfkill / radio killswitches
+KERNEL=="rfkill", SUBSYSTEM=="misc", TAG+="uaccess"
+
+# AV production controllers
+# Most of these devices use HID for the knobs, faders, buttons, encoders, and jog wheels.
+SUBSYSTEM=="hidraw", ENV{ID_AV_PRODUCTION_CONTROLLER}=="1", TAG+="uaccess"
+
+# Some devices use vendor defined protocols on USB Bulk endpoints for controllers.
+# Other devices transfer graphics to screens on the device through USB Bulk endpoints.
+# This also allows accessing HID devices with the libusb backend of hidapi.
+SUBSYSTEM=="usb", ENV{ID_AV_PRODUCTION_CONTROLLER}=="1", TAG+="uaccess"
+
+LABEL="uaccess_end"
diff --git a/rules.d/71-seat.rules.in b/rules.d/71-seat.rules.in
new file mode 100644
index 0000000000..25e4ee7e58
--- /dev/null
+++ b/rules.d/71-seat.rules.in
@@ -0,0 +1,81 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+#
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+ACTION=="remove", GOTO="seat_end"
+
+TAG=="uaccess", SUBSYSTEM!="sound", TAG+="seat"
+SUBSYSTEM=="sound", KERNEL=="card*", TAG+="seat"
+SUBSYSTEM=="input", KERNEL=="input*", TAG+="seat"
+SUBSYSTEM=="graphics", KERNEL=="fb[0-9]*", TAG+="seat"
+
+# Assign keyboard and LCD backlights to the seat
+SUBSYSTEM=="leds", TAG+="seat"
+SUBSYSTEM=="backlight", TAG+="seat"
+
+# Allow efifb / uvesafb to be a master if KMS is disabled
+SUBSYSTEM=="graphics", KERNEL=="fb[0-9]", IMPORT{cmdline}="nomodeset", TAG+="master-of-seat"
+
+# Allow any PCI graphics device to be a master and synthesize a seat if KMS
+# is disabled and the kernel doesn't have a driver that would work with this device.
+SUBSYSTEM=="pci", ENV{ID_PCI_CLASS_FROM_DATABASE}=="Display controller", \
+ ENV{DRIVER}=="", IMPORT{cmdline}="nomodeset", TAG+="seat", TAG+="master-of-seat"
+
+# Synthesize a seat for graphic devices without DRM and that fall back to fb
+# device instead. Such HWs are listed in hwdb.
+SUBSYSTEM=="graphics", KERNEL=="fb[0-9]*", ATTRS{modalias}=="?*", IMPORT{builtin}="hwdb fb:$attr{modalias}"
+ENV{ID_TAG_MASTER_OF_SEAT}=="1", TAG+="master-of-seat"
+
+SUBSYSTEM=="drm", KERNEL=="card[0-9]*", TAG+="seat", TAG+="master-of-seat"
+
+# Allow individual USB ports to be assigned to a seat
+SUBSYSTEM=="usb", ATTR{bDeviceClass}=="00", TAG+="seat"
+
+# Allow USB hubs (and all downstream ports) to be assigned to a seat
+SUBSYSTEM=="usb", ATTR{bDeviceClass}=="09", TAG+="seat"
+
+# 'Plugable' USB hub, sound, network, graphics adapter
+SUBSYSTEM=="usb", ATTR{idVendor}=="2230", ATTR{idProduct}=="000[13]", ENV{ID_AUTOSEAT}="1"
+
+# qemu (version 2.4+) has a PCI-PCI bridge (-device pci-bridge-seat) to group
+# devices belonging to one seat. See:
+# http://git.qemu.org/?p=qemu.git;a=blob;f=docs/multiseat.txt
+SUBSYSTEM=="pci", ATTR{vendor}=="0x1b36", ATTR{device}=="0x000a", TAG+="seat", ENV{ID_AUTOSEAT}="1"
+
+# Mimo 720, with integrated USB hub, displaylink graphics, and e2i
+# touchscreen. This device carries no proper VID/PID in the USB hub,
+# but it does carry good ID data in the graphics component, hence we
+# check it from the parent. There's a bit of a race here however,
+# given that the child devices might not exist yet at the time this
+# rule is executed. To work around this we'll trigger the parent from
+# the child if we notice that the parent wasn't recognized yet.
+
+# Match parent
+{% raw -%}
+SUBSYSTEM=="usb", ATTR{idVendor}=="058f", ATTR{idProduct}=="6254", \
+ ATTR{%k.2/idVendor}=="17e9", ATTR{%k.2/idProduct}=="401a", ATTR{%k.2/product}=="mimo inc", \
+ ENV{ID_AUTOSEAT}="1", ENV{ID_AVOID_LOOP}="1"
+{% endraw %}
+
+# Match child, look for parent's ID_AVOID_LOOP
+SUBSYSTEM=="usb", ATTR{idVendor}=="17e9", ATTR{idProduct}=="401a", ATTR{product}=="mimo inc", \
+ ATTR{../idVendor}=="058f", ATTR{../idProduct}=="6254", \
+ IMPORT{parent}="ID_AVOID_LOOP"
+
+# Match child, retrigger parent
+SUBSYSTEM=="usb", ATTR{idVendor}=="17e9", ATTR{idProduct}=="401a", ATTR{product}=="mimo inc", \
+ ATTR{../idVendor}=="058f", ATTR{../idProduct}=="6254", \
+ ENV{ID_AVOID_LOOP}=="", \
+ RUN+="{{ROOTBINDIR}}/udevadm trigger --parent-match=%p/.."
+
+TAG=="seat", ENV{ID_PATH}=="", IMPORT{builtin}="path_id"
+TAG=="seat", ENV{ID_FOR_SEAT}=="", ENV{ID_PATH_TAG}!="", ENV{ID_FOR_SEAT}="$env{SUBSYSTEM}-$env{ID_PATH_TAG}"
+
+SUBSYSTEM=="input", ATTR{name}=="Wiebetech LLC Wiebetech", RUN+="{{ROOTBINDIR}}/loginctl lock-sessions"
+
+LABEL="seat_end"
diff --git a/rules.d/73-seat-late.rules.in b/rules.d/73-seat-late.rules.in
new file mode 100644
index 0000000000..7cda2b08ce
--- /dev/null
+++ b/rules.d/73-seat-late.rules.in
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+#
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+ACTION=="remove", GOTO="seat_late_end"
+
+ENV{ID_SEAT}=="", ENV{ID_AUTOSEAT}=="1", ENV{ID_FOR_SEAT}!="", ENV{ID_SEAT}="seat-$env{ID_FOR_SEAT}"
+ENV{ID_SEAT}=="", IMPORT{parent}="ID_SEAT"
+
+ENV{ID_SEAT}!="", TAG+="$env{ID_SEAT}"
+{% if HAVE_ACL %}
+TAG=="uaccess", ENV{MAJOR}!="", RUN{builtin}+="uaccess"
+{% endif %}
+
+LABEL="seat_late_end"
diff --git a/rules.d/meson.build b/rules.d/meson.build
index f725e14d95..a391390292 100644
--- a/rules.d/meson.build
+++ b/rules.d/meson.build
@@ -4,54 +4,71 @@ install_data(
'README',
install_dir : udevrulesdir)
-rules = files(
- '60-autosuspend.rules',
- '60-block.rules',
- '60-cdrom_id.rules',
- '60-drm.rules',
- '60-evdev.rules',
- '60-fido-id.rules',
- '60-input-id.rules',
- '60-persistent-alsa.rules',
- '60-persistent-input.rules',
- '60-persistent-storage.rules',
- '60-persistent-storage-tape.rules',
- '60-persistent-v4l.rules',
- '60-sensor.rules',
- '60-serial.rules',
- '70-camera.rules',
- '70-joystick.rules',
- '70-mouse.rules',
- '70-touchpad.rules',
- '75-net-description.rules',
- '75-probe_mtd.rules',
- '78-sound-card.rules',
- '80-net-setup-link.rules',
- '81-net-dhcp.rules')
-
-if conf.get('HAVE_KMOD') == 1
- rules += files('80-drivers.rules')
-endif
-
-if dmi_arches.contains(host_machine.cpu_family())
- rules += files('70-memory.rules')
-endif
-
-install_data(rules,
- install_dir : udevrulesdir)
-
-all_rules = rules
-
-rules_in = ['50-udev-default.rules',
- '64-btrfs.rules',
- '99-systemd.rules']
-
-foreach file : rules_in
- all_rules += custom_target(
- file,
- input : file + '.in',
- output: file,
+rules = [
+ [files('60-autosuspend.rules',
+ '60-block.rules',
+ '60-cdrom_id.rules',
+ '60-drm.rules',
+ '60-evdev.rules',
+ '60-fido-id.rules',
+ '60-input-id.rules',
+ '60-persistent-alsa.rules',
+ '60-persistent-input.rules',
+ '60-persistent-storage.rules',
+ '60-persistent-storage-tape.rules',
+ '60-persistent-v4l.rules',
+ '60-sensor.rules',
+ '60-serial.rules',
+ '70-camera.rules',
+ '70-joystick.rules',
+ '70-mouse.rules',
+ '70-touchpad.rules',
+ '75-net-description.rules',
+ '75-probe_mtd.rules',
+ '78-sound-card.rules',
+ '80-net-setup-link.rules',
+ '81-net-dhcp.rules',
+ )],
+
+ [files('80-drivers.rules'),
+ conf.get('HAVE_KMOD') == 1],
+
+ [files('70-memory.rules'),
+ dmi_arches.contains(host_machine.cpu_family())],
+]
+
+all_rules = []
+
+foreach tuple : rules
+ if tuple.length() == 1 or tuple[1]
+ install_data(tuple[0],
+ install_dir : udevrulesdir)
+ all_rules += tuple[0]
+ endif
+endforeach
+
+rules_in = [
+ ['50-udev-default.rules'],
+ ['64-btrfs.rules'],
+ ['99-systemd.rules'],
+
+ ['70-uaccess.rules', enable_logind and conf.get('HAVE_ACL') == 1],
+ ['71-seat.rules', enable_logind],
+ ['73-seat-late.rules', enable_logind],
+]
+
+foreach tuple : rules_in
+ want = tuple.length() == 1 or tuple[1]
+
+ rule = custom_target(
+ tuple[0],
+ input : tuple[0] + '.in',
+ output: tuple[0],
command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
- install : true,
+ install : want,
install_dir : udevrulesdir)
+
+ if want
+ all_rules += rule
+ endif
endforeach