[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

How to expand sudo environment when -E doesn't



I find sudo to be particularly ill informed at times.

For example:  Attempting to run a `for' loop

as user:

for ii in 1 2 3;do echo $ii;done
1
2
3

as sudoer:

  sudo for ii in 1 2 3;do echo $ii;done 
  bash: syntax error near unexpected token `do'

It doesn't know about bash builtins.

Adding the -E flag (preserve environment) doe not help at all.

  sudo -E for ii in 1 2 3;do echo $ii;done 
  bash: syntax error near unexpected token `do'

A couple of settings in /etc/sudoers that may have some effect seem to
be set to sensible defaults:

from /etc/sudoers:

  Defaults env_reset
  Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

-------        ---------       ---=---       ---------      -------- 

What can I do to avoid this kind of silliness?  What kind of
environment variable would even tell sudo about bash builtins?




Reply to: