systemd-udevd does not work as expected using custom rules

Bug #1641440 reported by koffeinfriedhof
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

Hi!

In this example I'm using an external USB-Keyboard to trigger a rule on plugin/-off. The same example works in Arch, but not in (K)Ubuntu 16.10.

System:
Thinkpad X220:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.10
Release: 16.10
Codename: yakkety
Kernel: Linux x220 4.8.0-27-generic #29-Ubuntu SMP Thu Oct 20 21:03:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

I used following steps to reproduce:

Check device:
cmd: lsusb
output: Bus 001 Device 005: ID 1267:0103 Logic3 / SpectraVideo plc G-720 Keyboard

cmd: udevadm monitor
1.Plugin keyboard
2.Check shortest path
my example: /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2

cmd: udevadm -a -p /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2 | egrep "SUBSYSTEM|idProduct|idVendor"
output:
SUBSYSTEM=="usb"
ATTR{idProduct}=="0103"
ATTR{idVendor}=="1267"

Create rule:
nano /etc/udev/rules.d/99-numlocker.rules

content: ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="1267", ATTRS{idProduct}=="0103" RUN+="/bin/sh -c '/usr/bin/touch /home/kubuntu/plugged'", ENV{REMOVE_CMD}="/bin/sh -c '/bin/rm /home/kubuntu/plugged'"}}}

Test rule:
cmd: udevadm test /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2

shortened output:
...Reading rules file: /lib/udev/rules.d/99-systemd.rules
rules contain 393216 bytes tokens (32768 * 12 bytes), 37025 bytes strings
27127 strings (224162 bytes), 23453 de-duplicated (190812 bytes), 3675 trie nodes used
value '[dmi/id]sys_vendor' is 'LENOVO'
value '[dmi/id]sys_vendor' is 'LENOVO'
IMPORT builtin 'usb_id' /lib/udev/rules.d/50-udev-default.rules:13
IMPORT builtin 'hwdb' /lib/udev/rules.d/50-udev-default.rules:13
MODE 0664 /lib/udev/rules.d/50-udev-default.rules:41
PROGRAM 'mtp-probe /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2 1 6' /lib/udev/rules.d/69-libmtp.rules:2167
starting 'mtp-probe /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2 1 6'
'mtp-probe /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2 1 6'(out) '0'
Process 'mtp-probe /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2 1 6' succeeded.
RUN '/lib/udev/tlp-usb-udev %p' /lib/udev/rules.d/85-tlp.rules:10
RUN '/bin/sh -c '/bin/rm /home/kubuntu/plugged'' /etc/udev/rules.d/99-numlocker.rules:6
handling device node '/dev/bus/usb/001/006', devnum=c189:5, mode=0664, uid=0, gid=0
preserve permissions /dev/bus/usb/001/006, 020664, uid=0, gid=0
preserve already existing symlink '/dev/char/189:5' to '../bus/usb/001/006'
created db file '/run/udev/data/c189:5' for '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2'
ACTION=add
BUSNUM=001
DEVNAME=/dev/bus/usb/001/006
DEVNUM=006
DEVPATH=/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2
DEVTYPE=usb_device
DRIVER=usb
ID_BUS=usb
ID_MODEL=0103
ID_MODEL_ENC=0103
ID_MODEL_FROM_DATABASE=G-720 Keyboard
ID_MODEL_ID=0103
ID_REVISION=0101
ID_SERIAL=1267_0103
ID_USB_INTERFACES=:030101:030000:
ID_VENDOR=1267
ID_VENDOR_ENC=1267
ID_VENDOR_FROM_DATABASE=Logic3 / SpectraVideo plc
ID_VENDOR_ID=1267
MAJOR=189
MINOR=5
PRODUCT=1267/103/101
REMOVE_CMD=/bin/sh -c '/bin/rm /home/kubuntu/plugged'
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=68681993
run: '/lib/udev/tlp-usb-udev /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2'
run: '/bin/sh -c '/usr/bin/touch /home/kubuntu/plugged''
Unload module index
Unloaded link configuration context.

I've tried following to load rules:
> udevadm control -R
> systemctl restart systemd-udevd
> reboot

Nothing seems to work. Even after a few days and reboots it keeps the same,
BUT there's a "workaround":

After every reboot use:
systemctl stop systemd-udevd
systemctl start systemd-udevd

and the rule works.

Could anyone give me a hint why this does not work as expected in Kubuntu 16.10 or can confirm this?

Thanks in advance!

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https://wiki.ubuntu.com/Bugs/FindRightPackage. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.

To change the source package that this bug is filed about visit https://bugs.launchpad.net/ubuntu/+bug/1641440/+editstatus and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
no longer affects: systemd (Ubuntu)
affects: ubuntu → systemd (Ubuntu)
Dan Streetman (ddstreet)
Changed in systemd (Ubuntu):
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.