On Friday 18 May 2007 10:00, Ignacio García Pérez wrote:
> Sorry to bring the topic again. Someone pointed out that udevd should be
> passing the environment variables it gets on startup to its spawned
> child processes, thus letting the use actually decide what should be and
> not be in the environment.
>
> I would like to point out that while revieving the udevd code I found
> out that udevd actively (by means of a call to clearenv) clears the
> environment variables of all forked processes, which of course includes
> all programs called via the "RUN" directive in the rules files.
>
> As I mentioned earlier, I solved the problem with a generic rule in a
> file named to be included before all others:
>
> ACTION=="*", ENV{PATH}="/sbin:/usr/sbin:/bin:/usr/bin"
>
> However, I still don't know why my FC6 setup does not include such a
> rule but still works fine (yes, the Red Hat patches don't remove the
> clearenv).
I sent a patch to udev people to preserve PATH. See attached.
Hopefully they can apply it.
--
vda
--- udev-111.org/udevd.c Thu May 10 12:42:56 2007
+++ udev-111/udevd.c Fri May 18 13:00:37 2007
@@ -950,6 +950,8 @@
};
int rc = 1;
int maxfd;
+ /* strduping: it has to survive clearenv: */
+ const char *saved_PATH = strdup(getenv("PATH"));
logging_init("udevd");
udev_config_init();
@@ -1152,6 +1154,8 @@
/* clear environment for forked event processes */
clearenv();
+ if (saved_PATH)
+ setenv("PATH", saved_PATH, 1);
/* export log_priority , as called programs may want to follow that setting */
sprintf(udev_log, "UDEV_LOG=%i", udev_log_priority);
--- udev-111.org/udevstart.c Thu May 10 12:42:56 2007
+++ udev-111/udevstart.c Fri May 18 12:58:13 2007
@@ -38,6 +38,7 @@
#include "udev_rules.h"
#include "udev_selinux.h"
+static const char *saved_PATH;
static const char *udev_run_str;
static const char *udev_log_str;
static struct udev_rules rules;
@@ -109,6 +110,8 @@
/* clear and set environment for next event */
clearenv();
+ if (saved_PATH)
+ setenv("PATH", saved_PATH, 1);
setenv("ACTION", "add", 1);
setenv("UDEV_START", "1", 1);
if (udev_log_str)
@@ -339,6 +342,7 @@
selinux_init();
dbg("version %s", UDEV_VERSION);
+ saved_PATH = strdup(getenv("PATH")); /* it has to survive clearenv */
udev_run_str = getenv("UDEV_RUN");
udev_log_str = getenv("UDEV_LOG");
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox