mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2025-06-18 07:18:16 +00:00
Fix CT_SanitizePath
Replace the over-engineered and buggy test in CT_SanitizePath with a straight forward string pattern match, and also handle empty PATH elements which are qeuivalent to ".". Thanks-To: Arnaud Lacombe <lacombar@gmail.com> Signed-off-by: Johannes Stezenbach <js@sig21.net>
This commit is contained in:
committed by
Yann E. MORIN"
parent
143f02e0ce
commit
6d084fb565
@ -137,18 +137,16 @@ CT_DoEnd()
|
|||||||
CT_DoLog ${level:-INFO} "(elapsed: ${elapsed_min}:${elapsed_sec}.${elapsed_csec})"
|
CT_DoLog ${level:-INFO} "(elapsed: ${elapsed_min}:${elapsed_sec}.${elapsed_csec})"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove entries referring to ., /tmp and non-existing directories from $PATH
|
# Remove entries referring to . and other relative paths
|
||||||
# Usage: CT_SanitizePath
|
# Usage: CT_SanitizePath
|
||||||
CT_SanitizePath() {
|
CT_SanitizePath() {
|
||||||
local new
|
local new
|
||||||
local tmp
|
local p
|
||||||
local IFS=:
|
local IFS=:
|
||||||
for p in $PATH; do
|
for p in $PATH; do
|
||||||
# Replace any occurence of . with $(pwd -P)
|
# Only accept absolute paths;
|
||||||
# Use /tmp as a default if the directory is non-existent
|
# Note: as a special case the empty string in PATH is equivalent to .
|
||||||
# Do not add /tmp in the PATH
|
if [ -n "${p}" -a -z "${p%%/*}" ]; then
|
||||||
tmp="$( cd /tmp; cd "${p}" 2>/dev/null || true; pwd -P )"
|
|
||||||
if [ "${tmp}" != "/tmp" ]; then
|
|
||||||
new="${new}${new:+:}${p}"
|
new="${new}${new:+:}${p}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
Reference in New Issue
Block a user