File tree Expand file tree Collapse file tree 5 files changed +54
-6
lines changed
Expand file tree Collapse file tree 5 files changed +54
-6
lines changed Original file line number Diff line number Diff line change 1010set -eu
1111
1212{%- if osx %}
13- unset DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH
13+ unset DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH DYLD_INSERT_LIBRARIES DYLD_FRAMEWORK_PATH
1414{%- else %}
15- export OLD_LD_LIBRARY_PATH=" ${LD_LIBRARY_PATH:- } "
16- unset LD_LIBRARY_PATH
15+ unset LD_LIBRARY_PATH LD_PRELOAD LD_AUDIT
1716{%- endif %}
1817
1918if ! echo " $0 " | grep ' \.sh$' > /dev/null; then
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ logger -p "install.info" "$1" || echo "$1"
2020
2121{%- set channels = final_channels| join(" ," ) %}
2222
23- unset DYLD_LIBRARY_PATH
23+ unset DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH DYLD_INSERT_LIBRARIES DYLD_FRAMEWORK_PATH
2424
2525PREFIX=" $2 /{{ pkg_name_lower }}"
2626PREFIX=$( cd " $PREFIX " ; pwd)
Original file line number Diff line number Diff line change @@ -3,4 +3,3 @@ set -euxo pipefail
33
44echo " Hello: PREFIX='$PREFIX '"
55echo " LD_LIBRARY_PATH: ${LD_LIBRARY_PATH:- } "
6- echo " OLD_LD_LIBRARY_PATH: ${OLD_LD_LIBRARY_PATH:- } "
Original file line number Diff line number Diff line change @@ -23,12 +23,43 @@ test "${CUSTOM_VARIABLE_2}" = '$ECOND-CUSTOM_'\''STRING'\'' WITH SPACES AND @*!
2323
2424test " ${INSTALLER_UNATTENDED} " = " 1"
2525
26- if [[ $( uname -s) == Linux ]]; then
26+ # Print to stderr if any of the input variables are set, and returns 1 - otherwise 0.
27+ # Note that variables that are set but are empty strings will also trigger an error.
28+ # All input variables are checked before exit.
29+ verify_var_is_unset () {
30+ local failed=0
31+ for var in " $@ " ; do
32+ if [[ -n " ${! var+x} " ]]; then
33+ echo " Error: environment variable $var must be unset." >&2
34+ failed=1
35+ fi
36+ done
37+ return $failed
38+ }
39+
40+ if [[ $( uname -s) == " Linux" ]]; then
2741 if [[ ${INSTALLER_PLAT} != linux-* ]]; then
42+ echo " Error: INSTALLER_PLAT must match 'linux-*' on Linux systems."
43+ exit 1
44+ fi
45+
46+ if ! verify_var_is_unset LD_LIBRARY_PATH LD_PRELOAD LD_AUDIT; then
47+ echo " Error: One or more of LD_LIBRARY_PATH, LD_PRELOAD, or LD_AUDIT are set."
2848 exit 1
2949 fi
50+
3051else # macOS
3152 if [[ ${INSTALLER_PLAT} != osx-* ]]; then
53+ echo " Error: INSTALLER_PLAT must match 'osx-*' on macOS systems."
54+ exit 1
55+ fi
56+
57+ if ! verify_var_is_unset \
58+ DYLD_LIBRARY_PATH \
59+ DYLD_FALLBACK_LIBRARY_PATH \
60+ DYLD_INSERT_LIBRARIES \
61+ DYLD_FRAMEWORK_PATH; then
62+ echo " Error: One or more DYLD_* environment variables are set."
3263 exit 1
3364 fi
3465fi
Original file line number Diff line number Diff line change 1+ ### Enhancements
2+
3+ * Unset additional environment variables in shell-based installers to avoid accidental loading of external libraries. (#1082)
4+
5+ ### Bug fixes
6+
7+ * <news item>
8+
9+ ### Deprecations
10+
11+ * <news item>
12+
13+ ### Docs
14+
15+ * <news item>
16+
17+ ### Other
18+
19+ * <news item>
You can’t perform that action at this time.
0 commit comments