Skip to contentSkip to conversation

Starting helper programs - explicit check instead of just adding

DISCUSSION Matthias Schwarzott 2 participants 2 messages Mar 29, 2007

lore
Share & tools
lore
#0 lore raw

Hi there!

Generally executing udev-helper programs located in /lib/udev works well (without specifying a path).
Only one rule I use, just does not work like one could think:

SUBSYSTEM="pnp", ENV{MODALIAS}!="?*", RUN+="/bin/sh -c 'while read id; do /lib/udev/modprobe.sh pnp:d$$id; done < /sys$devpath/id'"

Here I have to explicitly give the full path to modprobe.sh.

The code uses this to look for not fully qualified pathes:

if (strchr(argv[0], '/') = NULL) {
                strlcpy(program, "/lib/udev/", sizeof(program));
                strlcat(program, argv[0], sizeof(program));
                argv[0] = program;
        }

...
execv(argv[0], argv);

And that only looks at the main program started in the cmd-line and not what this shell does.

Is this something that could be changed?
By e.g. using some exec-call respecting path?
Or keeping the code as it is, but still adding /lib/udev to PATH for such embedded calls to work like one could assume with common-sense?

Matthias

Signature · 11 lines
Matthias Schwarzott (zzam)

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#1 lore raw
Quoted 9 lines · Matthias Schwarzott

Generally executing udev-helper programs located in /lib/udev works well (without specifying a path).
Only one rule I use, just does not work like one could think:

SUBSYSTEM="pnp", ENV{MODALIAS}!="?*", RUN+="/bin/sh -c 'while read id; do /lib/udev/modprobe.sh pnp:d$$id; done < /sys$devpath/id'"

Here I have to explicitly give the full path to modprobe.sh.

Quoted 7 lines

And that only looks at the main program started in the cmd-line and not what this shell does.

Is this something that could be changed?
By e.g. using some exec-call respecting path?
Or keeping the code as it is, but still adding /lib/udev to PATH for such embedded calls to work like one could assume with common-sense?

It's the expected behavior, we don't want to stat() all over the place, to find the programs.
You can set the path with:
ENV{PATH}="/lib/udev:/bin:/sbin"
in any earlier rule, and the udev-forked shell will find all the commands in /lib/udev.

Thanks,
Kay

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel