diff options
author | Roy Marples <roy@marples.name> | 2007-11-28 13:40:15 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2007-11-28 13:40:15 +0000 |
commit | d651155b61a6f9ca3fe53e60718f3b43e04b23c8 (patch) | |
tree | f0bd9abdc7b9d34daab078ae7f8b186781228ac4 /sh | |
parent | 8ea741d6994c66df1c2a3851ea1a806e8c87e249 (diff) |
Sanitize our PATH a bit better, and terminate it correctly in start-stop-daemon.
Diffstat (limited to 'sh')
-rw-r--r-- | sh/functions.sh | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/sh/functions.sh b/sh/functions.sh index 79aeb3bf..db09d0b6 100644 --- a/sh/functions.sh +++ b/sh/functions.sh @@ -137,6 +137,16 @@ KV_to_int() { echo "${KV_int}" } +_sanitize_path() { + local IFS=":" p= + for p in ${PATH}; do + case "${p}" in + /lib/rc/sbin|/bin|/sbin|/usr/bin|/usr/sbin|/usr/local/bin|/usr/local/sbin) ;; + *) printf "%s" ":${p}";; + esac + done +} + # Allow our scripts to support zsh if [ -n "${ZSH_VERSION}" ] ; then emulate sh @@ -147,14 +157,9 @@ if [ -n "${ZSH_VERSION}" ] ; then setopt NO_GLOB_SUBST fi -# Setup a basic $PATH. Just add system default to existing. -# This should solve both /sbin and /usr/sbin not present when -# doing 'su -c foo', or for something like: PATH= rcscript start -case "${PATH}" in - /lib/rc/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin) ;; - /lib/rc/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:*) ;; - *) export PATH="/lib/rc/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:${PATH}" ;; -esac +# Add our bin to $PATH +export PATH="/lib/rc/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin$(_sanitize_path "${PATH}")" +unset _sanitize_path for arg in "$@" ; do case "${arg}" in |