Skip to contentSkip to conversation

udev rules file validation

DISCUSSION Alesh Slovak 4 participants 7 messages Sep 4, 2009 – Sep 15, 2009

lore
Share & tools
lore
#0 lore raw

Dear list,

I am a developer on iscan, which is a SANE driver and frontend for Epson scanners.

We try to support the broadest range of distributions possible with our packages. One of the ways in which we do this is by generating our udev rules files automatically from existing rules files we find on the system. Namely, rules files for other scanners that have been prepared by the distribution. This also gives us the added benefit of following distribution access policies without having to constantly keep up with them.

There seems to have been a change in udev recently that causes it to abort if it encounters a broken rules file. This causes boot failures. After this happened to iscan's packages with Debian testing, we became aware of a bug in our generation script that had always been there, but had gone unnoticed until the aforementioned changes were made to udev.

Of course, we fixed the bug, but in order to avoid this kind of problem in the future, I wanted to find a way to validate our udev rules files using udev itself, before actually installing them. I was able to come up with a fairly round-about way of validating a rules file using the output of the following command:
UDEV_CONFIG_FILE=temp.conf udevadm test NULL

The configuration file temp.conf simply points to a temporary directory containing the candidate udev rules file to avoid any possible interference from other rules files on the system. I used NULL for the device because I just want udev to load my rules file and tell me if there is anything wrong with it and udevadm test won't do anything unless I specify *something* for the device.

I wanted to get some opinions from the udev developers on this admittedly somewhat flimsy method for udev rules file validation and whether there are any better ways to do this that I am overlooking. I would appreciate any comments or suggestions.

Regards,
Alesh

#1 lore raw
Quoted 2 lines · Alesh Slovak

There seems to have been a change in udev recently that causes it to abort if it encounters a broken rules file. This causes boot failures.

FYI, this has since been fixed.

Signature · 2 lines
ciao,
Marco
#2 lore raw
In reply to Alesh Slovak
Quoted 5 lines · On Fri-2009/09/04-02:06 Alesh Slovak wrote:

UDEV_CONFIG_FILE=temp.conf udevadm test NULL

The configuration file temp.conf simply points to a temporary directory containing the candidate udev rules file to avoid any possible interference from other rules files on the system.

What is meant by "temp.conf simply points to a temporary directory containing the candidate udev rules"? I can find only the directives "udev_root" and "udev_log" but none specifying the location of rule files.

clemens

#3 lore raw
In reply to Alesh Slovak
Quoted 4 lines · clemens fischer
Quoted 2 lines · On Fri-2009/09/04-02:06 Alesh Slovak wrote:

UDEV_CONFIG_FILE=temp.conf udevadm test NULL

Quoted 8 lines
Quoted 3 lines

The configuration file temp.conf simply points to a temporary directory containing the candidate udev rules file to avoid any possible interference from other rules files on the system.

What is meant by "temp.conf simply points to a temporary directory containing the candidate udev rules"? I can find only the directives "udev_root" and "udev_log" but none specifying the location of rule files.

There is also a "udev_rules" directive. I create "temp.conf" that defines this to the same location as where I generate the udev rules file I wish to validate.

#4 lore raw
In reply to Alesh Slovak
Quoted 3 lines · Marco d'Itri
Quoted 2 lines

There seems to have been a change in udev recently that causes it to abort if it encounters a broken rules file. This causes boot failures.

FYI, this has since been fixed.

Despite this being fixed, I would still like to be able to validate my generated udev rules files. Anyone have any ideas?

Signature · 2 lines
Alesh Slovak                    Linux Team -- AVASYS Corporation
[email protected]          http://avasys.jp
#5 lore raw
In reply to Alesh Slovak

I donot understand what you mean by validate. It could have several meanings. For Example.
1. We could have something like XML/Document Validation. Much more seen in SGML/XML Environment.
2. We could have Run Time Validation Like Certificates. Much More of an RSS/Feed Environment/Web site Design.
3. We could have Validation of Resources. Having an inbuilt database of the resources udev is trying to load/unload/link.
4. We could have validation of the functionality of the generated script or an already present script.

By Validation what do you mean?

Quoted 18 lines · Alesh Slovak
Quoted 5 lines · Marco d'Itri
Quoted 3 lines

There seems to have been a change in udev recently that causes it to abort if it encounters a broken rules file. This causes boot failures.

FYI, this has since been fixed.

Despite this being fixed, I would still like to be able to validate my generated udev rules files. Anyone have any ideas?

--
Alesh Slovak                    Linux Team -- AVASYS Corporation [email protected]          http://avasys.jp
--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
-- Sujit K M

blog(http://kmsujit.blogspot.com/)
#6 lore raw
In reply to Alesh Slovak
Quoted 11 lines · Sujit K M

I donot understand what you mean by validate. It could have several meanings. For Example.
1. We could have something like XML/Document Validation. Much more seen in SGML/XML Environment.
2. We could have Run Time Validation Like Certificates. Much More of an RSS/Feed Environment/Web site Design.
3. We could have Validation of Resources. Having an inbuilt database of the resources udev is trying to load/unload/link.
4. We could have validation of the functionality of the generated script or an already present script.

Quoted 1 line

By Validation what do you mean?

What I mean by validating udev rules files is probably closest to #1 above. Because I generate udev rules automagically with a script at install time I would like to be sure that the rules files are formatted correctly before installing them on the system and potentially screwing things up (like happened before). I could write my own validation script but if there is a good way to validate rules files using udev itself, that would obviously be the better way to go.

Regards,

Signature · 2 lines
Alesh Slovak                    Linux Team -- AVASYS Corporation
[email protected]          http://avasys.jp