filter_readonly_variables: safe cwd, bug #469338
authorZac Medico <zmedico@gentoo.org>
Sun, 12 May 2013 20:11:50 +0000 (13:11 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 12 May 2013 20:11:50 +0000 (13:11 -0700)
bin/phase-functions.sh

index 76c97ac733d2d7b04d7d84cf242b36d02b8abf5f..ea717fe7caf37f06db6a40735ff1798e06c85fff 100644 (file)
@@ -582,9 +582,13 @@ __dyn_install() {
        # local variables can leak into the saved environment.
        unset f
 
+       # Use safe cwd, avoiding unsafe import for bug #469338.
+       cd "${PORTAGE_PYM_PATH}"
        __save_ebuild_env --exclude-init-phases | __filter_readonly_variables \
-               --filter-path --filter-sandbox --allow-extra-vars > environment
+               --filter-path --filter-sandbox --allow-extra-vars > \
+               "${PORTAGE_BUILDDIR}"/build-info/environment
        assert "__save_ebuild_env failed"
+       cd "${PORTAGE_BUILDDIR}"/build-info || die
 
        ${PORTAGE_BZIP2_COMMAND} -f9 environment
 
@@ -874,6 +878,8 @@ __ebuild_main() {
                if [[ -n $PORTAGE_UPDATE_ENV ]] ; then
                        # Update environment.bz2 in case installation phases
                        # need to pass some variables to uninstallation phases.
+                       # Use safe cwd, avoiding unsafe import for bug #469338.
+                       cd "${PORTAGE_PYM_PATH}"
                        __save_ebuild_env --exclude-init-phases | \
                                __filter_readonly_variables --filter-path \
                                --filter-sandbox --allow-extra-vars \
@@ -974,6 +980,8 @@ __ebuild_main() {
        # Save the env only for relevant phases.
        if ! has "${1}" clean help info nofetch ; then
                umask 002
+               # Use safe cwd, avoiding unsafe import for bug #469338.
+               cd "${PORTAGE_PYM_PATH}"
                __save_ebuild_env | __filter_readonly_variables \
                        --filter-features > "$T/environment"
                assert "__save_ebuild_env failed"