FS#18953 - [initscripts] udev incorrect $PATH passed to helpers

Attached to Project: Arch Linux
Opened by orbisvicis (orbisvicis) - Saturday, 03 April 2010, 23:53 GMT
Last edited by Andrea Scarpino (BaSh) - Wednesday, 22 December 2010, 22:31 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Tobias Powalowski (tpowa)
Aaron Griffin (phrakture)
Thomas Bächler (brain0)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:
The $PATH udev inherits and passes to helper applications is incomplete:
/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.

Additional info:
* package version(s)
core/udev 151-3 (base)

Steps to reproduce:
in one of the /lib/udev/* helper scripts add:
logger "gpsd.hotplug.wrapper path is: $PATH"
This task depends upon

Closed by  Andrea Scarpino (BaSh)
Wednesday, 22 December 2010, 22:31 GMT
Reason for closing:  Fixed
Additional comments about closing:  http://projects.archlinux.org/initscript s.git/commit/?id=b1f25405aeb7baff194aac4 473c8c6692c3d8bea
Comment by orbisvicis (orbisvicis) - Sunday, 04 April 2010, 00:41 GMT
From what I google older versions of udev used to clear the $PATH environment variable but not anymore.

Since /etc/profile is sourced after the boot-up process, it doesn't affect the $PATH that udev inherits.

I see two ways to modify the $PATH udev inherits:

in /etc/rc.sysinit (and possibly also in rc.single) call udev as
PATH="..." /sbin/udevd --daemon
^ does this need to be prefixed with "export"?

in /lib/udev/rules.d/ add a rule "00-paths.rule" containing
ACTION=="*", ENV{PATH}="..."


First to consider: is it a good idea to change udev's $PATH? If so, is it preferable to set the $PATH correctly for all applications in /etc/rc.sysinit, or only for udev? (this would render /etc/profile a bit redundant)
Comment by Thomas Bächler (brain0) - Friday, 30 April 2010, 07:32 GMT
That's not only a udev problem. Everything started by initscripts inherits a default path, one which doesn't include {/usr,}/sbin for example. This has not caused any problems so far.
Comment by Aaron Griffin (phrakture) - Friday, 30 April 2010, 17:13 GMT
Actually, I wouldn't say that it is incomplete. It's just unexpected.

Which scripts, in particular, are failing here? Just use the full path and everything works fine.

There is no single unified place to define the system PATH. It's based on the shell
Comment by orbisvicis (orbisvicis) - Saturday, 01 May 2010, 16:32 GMT
Unexpected means non-standard. I believe Arch is the only major distribution (Ubuntu - Debian - Fedora) required to patch helper programs called by udev rules to include the full path.

For example - possibly the only example - the gpsd helper program "/lib/udev/gpsd.hotplug" needs modification.

Line 49 @ http://repos.archlinux.org/wsvn/community/gpsd/trunk/PKGBUILD
sed -i 's|gpsdcmd = "gpsd %s|gpsdcmd = "/usr/sbin/gpsd %s|' gpsd.hotplug
Comment by Aaron Griffin (phrakture) - Sunday, 02 May 2010, 02:21 GMT
What you are seeing IS, in fact, bash's default path. That's about as standard as it gets.

The reason bash is using its default path is that it is started non-interactively without a parent process giving it a PATH.

How do we change this? No idea. Please look into how the other distros you referenced do it. My guess is that they set BASH_ENV, or perhaps even export PATH before calling init for the first time.
Comment by Thomas Bächler (brain0) - Sunday, 02 May 2010, 17:43 GMT
I believe PATH is inherited from the parent, and a non-interactive shell does not replace it.
Comment by Aaron Griffin (phrakture) - Monday, 03 May 2010, 17:45 GMT
Right but the parent, in this case is init... does init inherit it from the initramfs code?
Comment by Thomas Bächler (brain0) - Monday, 03 May 2010, 17:51 GMT
The parent is actually rc.sysinit.
Comment by Aaron Griffin (phrakture) - Monday, 03 May 2010, 18:03 GMT
So do we want to just set PATH in rc.sysinit? It seems a little hokey, but I guess it's not THAT bad.
Comment by Florian Pritz (bluewind) - Saturday, 03 July 2010, 16:26 GMT
decision?
Comment by Tom Gundersen (tomegun) - Thursday, 09 December 2010, 12:01 GMT
Could you try this patch: <https://github.com/teg/initscripts-arch/commit/aa947f924e273a37fd1492b14be1fad2d540979d>?

Let me know if there is a problem. If it does not work it is a bug in either systemd or udev (or the provider of the helper script), which I'd like to file upstream.
Comment by Thomas Bächler (brain0) - Thursday, 09 December 2010, 12:12 GMT
If we adopt a default path in rc.sysinit, we should be consistent - we do not include /usr/local/{s,}bin in any default paths so far (there was a discussion which surprisingly moved towards not including /local/ by default for weird reasons).
Comment by Tom Gundersen (tomegun) - Thursday, 09 December 2010, 18:09 GMT
@brain0: Maybe I'm confusing myself, but my patch adds the same PATH to rc.sysinit as is set in /etc/profile from "filesystem", is that not the standard one?
Comment by Thomas Bächler (brain0) - Thursday, 09 December 2010, 23:20 GMT
I just looked, and it seems my memory was playing tricks on me.

Loading...