Bug 851974

Summary: udev rule ordering ignored
Product: Red Hat Enterprise Linux 6 Reporter: Marko Myllynen <myllynen>
Component: halAssignee: Richard Hughes <rhughes>
Status: CLOSED WONTFIX QA Contact: Desktop QE <desktop-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.3CC: harald, msekleta, salmy, tpelka
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-06 12:24:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1270825    

Description Marko Myllynen 2012-08-27 07:52:50 UTC
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 10:35:48 UTC
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 12:50:02 UTC
(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 13:02:15 UTC
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 08:37:51 UTC
(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 Program Management 2013-10-14 04:49:57 UTC
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 13:49:11 UTC
(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.

Comment 13 Jan Kurik 2017-12-06 12:24:27 UTC
Red Hat Enterprise Linux 6 is in the Production 3 Phase. During the Production 3 Phase, Critical impact Security Advisories (RHSAs) and selected Urgent Priority Bug Fix Advisories (RHBAs) may be released as they become available.

The official life cycle policy can be reviewed here:

http://redhat.com/rhel/lifecycle

This issue does not meet the inclusion criteria for the Production 3 Phase and will be marked as CLOSED/WONTFIX. If this remains a critical requirement, please contact Red Hat Customer Support to request a re-evaluation of the issue, citing a clear business justification. Note that a strong business justification will be required for re-evaluation. Red Hat Customer Support can be contacted via the Red Hat Customer Portal at the following URL:

https://access.redhat.com/