udev and PATH problems

Ignacio García Pérez iggarpe at terra.es
Wed May 16 05:05:59 PDT 2007


Ok, I'm replying to myself with what I think is the best solution:

1- Rename (as FC6 and other distros do) the files in /etc/udev/rules.d 
to force a parse order (i.e. place a number prefix).

2- Create a "00-early.rules" file with the following content:

ACTION=="*", ENV{PATH}="/sbin:/bin:/usr/sbin:/usr/bin"



By the way, any suggestions on which should be the default "reasonable" 
path. The one I used above is what I get from a "echo $PATH" at my FC6 
box prompt, but busybox's ash seems to prefer the following:

/usr/sbin:/bin:/usr/bin:/sbin

Which one makes most sense?


> Hi,
>
> I have a small but quite annoying problem for which I can't find a 
> "good" solution. My setup is full custom, and I'm using udevd with a 
> custom set of rules. Things like this:
>
>
>
> ACTION=="add", SUBSYSTEM=="net", \
>     RUN+="/sbin/ifup $env{INTERFACE}"
>
>
>
> The problem is that when udevd runs /sbin/ifup, it does not pass a valid 
> PATH environment variable. Since ifup actually calls several external 
> programs (ifconfig, ip, route, etc), if the PATH is not correctly set, 
> they won't be found and ifup will fail miserably.
>
> Here's the solution I'm using right now:
>
>
>
> ACTION=="add", SUBSYSTEM=="net", \
>     ENV{PATH}="/sbin:/bin:/usr/sbin:/usr/bin", \
>     RUN+="/sbin/ifup $env{INTERFACE}"
>
>
>
> And yeah, works fine, but I must add the "ENV{PATH}=" directive on each 
> and every udev rule that runs a program, and that is far from a good 
> solution (plus bloats the rules files a lot).
>
> Anyone with a broader perspective can suggest a better solution?
>
> Best regards.
>
> P.S: I'm using FC6 for my desktop and noticed that it does not deal with 
> the PATH environment variable wherever it executes a program in a rule. 
> Has red hat patched udev?, or is it just that all external programs take 
> care of this themselves? (if the program is a shell script, it can set 
> the PATH right at the start, if the program is an executable binary, it 
> is ok not to have a PATH as long as you don't call other external 
> programs as busybox's ifup does...)
>
>
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox
>
>   



More information about the busybox mailing list