LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   envar PATH when run by udev - poor choice? (https://www.linuxquestions.org/questions/slackware-14/envar-path-when-run-by-udev-poor-choice-800501/)

catkin 04-07-2010 12:51 AM

envar PATH when run by udev - poor choice?
 
Hello :)

The value of envar PATH for processes run by the udev system is "/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.". If peer review (that's you!) agrees it is a poor choice how can I submit an enhancement request? The man pages do not say anything about bug reporting.

Here are reasons why it is a bizarre choice:
  • There is no /gnu/bin directory on as-installed Slackware.
  • /usr/local/bin is empty (or very nearly empty?) on as-installed Slackware.
  • Processes running under udev run as root; having "." in PATH is not good practice when running as root.
  • Processes running under udev are likely to be doing "system" work so executables from the sbin directories are likely to be used. For example, udevadm itself is /sbin/udevadm.
Presumably this PATH is set by udevd itself; it is not the PATH in effect when udevd is started by rc.M.

AFAIK udevd's PATH is not configurable.

The workaround is for processes initiated by udev to set a sane PATH for themselves, perhaps "/usr/sbin:/sbin:/usr/bin:/bin".

EDIT: seen on Slackware 13.0 32 bit.

EDIT2: rc.udev is run from rc.S, not rc.M as stated above :redface:

Best

Charles

unSpawn 04-07-2010 01:20 PM

Apparently older udevd cleaned PATH but not anymore (circumstantial). W/o need for patching, could starting Udev like 'env PATH=/usr/sbin:/sbin:/usr/bin:/bin /sbin/udevd --whatever-args' work? That is, if the "Steps to reproduce" method shows that helper apps inherit that path.

catkin 04-07-2010 02:21 PM

Quote:

Originally Posted by unSpawn (Post 3927730)
Apparently older udevd cleaned PATH but not anymore (circumstantial: ). W/o need for patching, could starting Udev like 'env PATH=/usr/sbin:/sbin:/usr/bin:/bin /sbin/udevd --whatever-args' work? That is, if the "Steps to reproduce" method shows that helper apps inherit that path.

Thanks unSpawn :) Have modified rc.udev and will report result after next reboot.

catkin 04-08-2010 12:42 AM

Further investigation confirms the initial impression that udev changes envar PATH, setting it to "/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:."
  1. During execution of rc.udev, immediately before starting the udev daemon, $PATH is "/sbin:/bin".
  2. The command used to start the udev daemon was modified to
    Code:

    env PATH=/usr/sbin:/sbin:/usr/bin:/bin/sbin/ udevd --daemon
  3. A script called via a udev rule was modified to log $PATH and showed "/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:."
Looking deeper, trying to find out where this PATH is set:
Code:

root@CW8:~# strings /sbin/udevd | grep sbin
root@CW8:~# file /sbin/udevd
/sbin/udevd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped
root@CW8:~# ldd /sbin/udevd
        linux-gate.so.1 =>  (0xffffe000)
        libc.so.6 => /lib/libc.so.6 (0xb7eb3000)
        /lib/ld-linux.so.2 (0xb802d000)

And there I got stuck.

mRgOBLIN 04-08-2010 01:07 AM

Perhaps an strace would reveal something.

catkin 04-08-2010 02:58 AM

Quote:

Originally Posted by mRgOBLIN (Post 3928241)
Perhaps an strace would reveal something.

Thanks mRgOBLIN :)

I tried that but the strace output stopped before a device could be plugged in. strace showed reading many udev rules and ended with
Code:

clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7d9c708) = 6604
munmap(0xb7d2d000, 163840)              = 0
close(4)                                = 0
close(5)                                = 0
exit_group(0)                          = ?

I guess it "exec"ed a new process and the new process was not "strac"ed ???

Unless there are any further suggestions on how to investigate this so I can make a more useful request, how can I submit an enhancement request?

catkin 04-15-2010 09:56 AM

Further investigation shows that the $PATH is bash' default so presumably udevd is not setting a PATH environment variable
Code:

c@CW8:~$ unset PATH
c@CW8:~$ /bin/bash
c@CW8:~$ echo $PATH
/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.


catkin 04-15-2010 10:00 AM

Quote:

Originally Posted by catkin (Post 3928294)
... how can I submit an enhancement request?

I sent an email to info <antelope> AT <fish> slackware.com asking them to consider modifying udevd to set a PATH or bash to have a default PATH that is useful on Slackware.


All times are GMT -5. The time now is 07:51 AM.