Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>PATH</code> is an environment variable, and as such is by default reset by sudo.</p> <p>You need special permissions to be permitted to do this. </p> <p>From <code>man sudo</code></p> <pre> -E The <b>-E</b> (preserve environment) option will override the env_reset option in sudoers(5)). It is only available when either the match- ing command has the SETENV tag or the setenv option is set in sudo- ers(5). </pre> <pre> Environment variables to be set for the command may also be passed on the command line in the form of <b>VAR</b>=value, e.g. <b>LD_LIBRARY_PATH</b>=/usr/local/pkg/lib. Variables passed on the command line are subject to the same restrictions as normal environment vari- ables with one important exception. If the setenv option is set in sudoers, the command to be run has the SETENV tag set or the command matched is ALL, the user may set variables that would overwise be for- bidden. See sudoers(5) for more information. </pre> <p>An Example of usage: </p> <pre><code>cat >> test.sh env | grep "MYEXAMPLE" ; ^D </code></pre> <pre class="lang-bash prettyprint-override"><code>sh test.sh MYEXAMPLE=1 sh test.sh # MYEXAMPLE=1 MYEXAMPLE=1 sudo sh test.sh MYEXAMPLE=1 sudo MYEXAMPLE=2 sh test.sh # MYEXAMPLE=2 </code></pre> <h3>update</h3> <pre> man 5 sudoers : env_reset If set, sudo will reset the environment to only contain the LOGNAME, SHELL, USER, USERNAME and the SUDO_* vari- ables. Any variables in the caller's environment that match the env_keep and env_check lists are then added. The default contents of the env_keep and env_check lists are displayed when sudo is run by root with the -V option. If sudo was compiled with the SECURE_PATH option, its value will be used for the PATH environment variable. This flag is on by default. </pre> <p>So may need to check that this is/is not compiled in. </p> <p>It is by default in <b>Gentoo</b></p> <pre class="lang-bash prettyprint-override"><code># ( From the build Script ) .... ROOTPATH=$(cleanpath /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin${ROOTPATH:+:${ROOTPATH}}) .... econf --with-secure-path="${ROOTPATH}" </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload