Bug 851974 - udev rule ordering ignored
udev rule ordering ignored
Status: ASSIGNED
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: hal (Show other bugs)
6.3
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: Richard Hughes
Desktop QE
:
Depends On:
Blocks: 1270825
  Show dependency treegraph
 
Reported: 2012-08-27 03:52 EDT by Marko Myllynen
Modified: 2017-09-14 07:53 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Marko Myllynen 2012-08-27 03:52:50 EDT
Description of problem:
When executing a simple script to debug udev rules [1] in /etc/udev/rules.d/10-test.rules [2], then udevadm test --action=add ... prints the actions to be executed for the target device as follows:

...
udevadm_test: run: '/tmp/test.sh add'
udevadm_test: run: 'socket:@/org/freedesktop/hal/udev_event

And when using /etc/udev/rules.d/99-test.rules instead, the ordering is changed (as expected):

...
udevadm_test: run: 'socket:@/org/freedesktop/hal/udev_event
udevadm_test: run: '/tmp/test.sh add'

But when actually inserting a device that matches the rules it can be seen from /var/log/messages that actually the test script is always executed before hal/udev_event (which triggers pcscd to initialize an etoken USB device on my test system, thus a custom script will fail to access the etoken device as it is not yet initialized properly by pcscd).

1)
localhost:~# cat /tmp/test.sh
#!/bin/sh
sleep 10
logger $0 $@ invoked

2)
SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", RUN+="/tmp/test.sh add"

Version-Release number of selected component (if applicable):
RHEL 6.3
Comment 2 Harald Hoyer 2012-09-06 06:35:48 EDT
Well, there is no guarantee, that after sending to 'socket:@/org/freedesktop/hal/udev_event' the initialization of the etoken device is immediately complete, when your test.sh is run. Maybe your test.sh should be triggered by hal then after the initialization and not by the udev event.
Comment 3 Marko Myllynen 2012-09-06 08:50:02 EDT
(In reply to comment #2)
> Well, there is no guarantee, that after sending to
> 'socket:@/org/freedesktop/hal/udev_event' the initialization of the etoken
> device is immediately complete, when your test.sh is run. Maybe your test.sh
> should be triggered by hal then after the initialization and not by the udev
> event.

This particular case I referred was just an example to illustrate that udev ignoring its own ordering rules is causing issues. I've already created a work around for this particular issue but IMHO udev should be fixed to follow its own rules.

Thanks.
Comment 4 Kay Sievers 2012-09-20 09:02:15 EDT
If I understand this issue correctly:

HAL is an asynchronous event-driven mechanism and does not block udev rules execution.

The event is delivered to HAL in the proper udev rules order, but executed by
HAL at any later time. 

I don't think you can expect a defined order when udev and HAL hooks are mixed,
they are just non synchronized, and this is the expected behaviour.
Comment 5 Marko Myllynen 2012-09-21 04:37:51 EDT
(In reply to comment #4)
> If I understand this issue correctly:
> 
> HAL is an asynchronous event-driven mechanism and does not block udev rules
> execution.
> 
> The event is delivered to HAL in the proper udev rules order, but executed by
> HAL at any later time. 

No, I don't think this is the case since in the example script there could be even something like "sleep 3600" and HAL still doesn't do anything meanwhile but only instantly after the script exits so it seems clearly indicate that the event is not delivered to HAL in the order manifested by udevadm test.

Thanks.
Comment 7 RHEL Product and Program Management 2013-10-14 00:49:57 EDT
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.
Comment 9 Michal Sekletar 2015-10-19 09:49:11 EDT
(In reply to Marko Myllynen from comment #5)

> No, I don't think this is the case since in the example script there could
> be even something like "sleep 3600" and HAL still doesn't do anything
> meanwhile but only instantly after the script exits so it seems clearly
> indicate that the event is not delivered to HAL in the order manifested by
> udevadm test.

I tried to reproduce this now, but in my case (KVM, in 99-test.rules trigger is addition of block device + running hal from command line with --daemon=no --verbose=yes) I can see from log produced by hal that it is notified about event *before* test script finishes. Reassigning to hal.

Note You need to log in before you can comment on or make changes to this bug.